From: Jeremy Tan Date: Fri, 25 Oct 2013 12:51:19 +0000 (+0800) Subject: Merge branch 'users' of https://github.com/szmoore/MCTX3420 into users X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=627505c91d4bb7be16dc0925ee9de54e007621a2;hp=72922bbdabbb097a7d8708e68ad9b2b5ea7911ce;p=matches%2FMCTX3420.git Merge branch 'users' of https://github.com/szmoore/MCTX3420 into users --- diff --git a/server/fastcgi.c b/server/fastcgi.c index 33f5257..af92efd 100644 --- a/server/fastcgi.c +++ b/server/fastcgi.c @@ -197,18 +197,17 @@ void FCGI_GetControlCookie(char buffer[CONTROL_KEY_BUFSIZ]) const char *cookies = getenv("COOKIE_STRING"); const char *start = strstr(cookies, "mctxkey="); + *buffer = 0; //Clear the buffer if (start != NULL) { - const char *end; - size_t limit = CONTROL_KEY_BUFSIZ; - start += 8; //Ah, magic numbers (the length of mctxkey= - 1) - end = strchr(start, ';'); - if (end != NULL && (end-start) < CONTROL_KEY_BUFSIZ) { - limit = (end-start) + 1; + int i; + start += 8; //length of mctxkey= + for (i = 0; i < CONTROL_KEY_BUFSIZ; i++) { + if (*start == 0 || *start == ';') { + break; + } + buffer[i] = *start++; } - snprintf(buffer, limit, "%s", start); - Log(LOGDEBUG, "buf: %s", buffer); - } else { - *buffer = 0; + buffer[i] = 0; } }