--------------------- PatchSet 1049 Date: 2004/08/15 21:10:05 Author: serassio Branch: nt Tag: (none) Log: Helper protocol changed to use URL escaped strings in Squid-3.0 Members: helpers/external_acl/win32_group/win32_check_group.c:1.2.18.6->1.2.18.7 Index: squid3/helpers/external_acl/win32_group/win32_check_group.c =================================================================== RCS file: /cvsroot/squid-sf//squid3/helpers/external_acl/win32_group/Attic/win32_check_group.c,v retrieving revision 1.2.18.6 retrieving revision 1.2.18.7 diff -u -r1.2.18.6 -r1.2.18.7 --- squid3/helpers/external_acl/win32_group/win32_check_group.c 27 Jun 2004 17:35:12 -0000 1.2.18.6 +++ squid3/helpers/external_acl/win32_group/win32_check_group.c 15 Aug 2004 21:10:05 -0000 1.2.18.7 @@ -30,6 +30,10 @@ * * History: * + * Version 1.21 + * 15-08-2004 Guido Serassio + * Helper protocol changed to use URL escaped strings in Squid-3.0 + * (Original work of Henrik Nordstrom) * Version 1.20 * 13-06-2004 Guido Serassio * Added support for running on a Domain Controller. @@ -89,51 +93,6 @@ #include "win32_check_group.h" -char * -strwordtok(char *buf, char **t) -{ - unsigned char *word = NULL; - unsigned char *p = (unsigned char *) buf; - unsigned char *d; - unsigned char ch; - int quoted = 0; - if (!p) - p = (unsigned char *) *t; - if (!p) - goto error; - while (*p && isspace(*p)) - p++; - if (!*p) - goto error; - word = d = p; - while ((ch = *p)) { - switch (ch) { - case '\\': - p++; - *d++ = ch = *p; - if (ch) - p++; - break; - case '"': - quoted = !quoted; - p++; - break; - default: - if (!quoted && isspace(*p)) { - p++; - goto done; - } - *d++ = *p++; - break; - } - } - done: - *d++ = '\0'; - error: - *t = (char *) p; - return (char *) word; -} - char * AllocStrFromLSAStr(LSA_UNICODE_STRING LsaStr) { @@ -523,7 +482,7 @@ int main (int argc, char *argv[]) { - char *p, *t; + char *p; char buf[BUFSIZE]; char *username; char *group; @@ -562,14 +521,16 @@ debug("Warning: running in case insensitive mode !!!\n"); /* Main Loop */ - while (fgets (buf, BUFSIZE, stdin)) + while (fgets (buf, sizeof(buf), stdin)) { if (NULL == strchr(buf, '\n')) { - err = 1; - continue; - } - if (err) { - fprintf(stderr, "Oversized message\n"); + /* too large message received.. skip and deny */ + fprintf(stderr, "%s: ERROR: Too large: %s\n", argv[0], buf); + while (fgets(buf, sizeof(buf), stdin)) { + fprintf(stderr, "%s: ERROR: Too large..: %s\n", argv[0], buf); + if (strchr(buf, '\n') != NULL) + break; + } goto error; } @@ -585,15 +546,18 @@ goto error; } - username = strwordtok(buf, &t); - for (n = 0; (group = strwordtok(NULL, &t)) != NULL; n++) + username = strtok(buf, " "); + for (n = 0; (group = strtok(NULL, " ")) != NULL; n++) { + rfc1738_unescape(group); groups[n] = group; + } groups[n] = NULL; if (NULL == username) { fprintf(stderr, "Invalid Request\n"); goto error; } + rfc1738_unescape(username); if ((use_global ? Valid_Global_Groups(username, groups) : Valid_Local_Groups(username, groups))) { printf ("OK\n"); @@ -601,7 +565,6 @@ error: printf ("ERR\n"); } - err = 0; } return 0; }