|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [1998-08-18 08:48 UTC] rasmus
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 05:00:02 2025 UTC | 
Using the SetCookie function set a long cookie containg lots of characters that need encoding. The following patch fixes the problem, the size of the value string was calculated before it was encoded, and the string gets larger after encoding. *** head.c.orig Fri Aug 7 22:37:32 1998 --- head.c Mon Aug 17 14:23:52 1998 *************** *** 233,239 **** CookieList *cookie; int len = 0; time_t t; ! char *r, *dt; #endif #if APACHE || defined(USE_SAPI) || FHTTPD char *tempstr; --- 233,239 ---- CookieList *cookie; int len = 0; time_t t; ! char *dt, *cookievalue = NULL; #endif #if APACHE || defined(USE_SAPI) || FHTTPD char *tempstr; *************** *** 259,266 **** while (cookie) { if (cookie->name) len += strlen(cookie->name); ! if (cookie->value) ! len += strlen(cookie->value); if (cookie->path) len += strlen(cookie->path); if (cookie->domain) --- 259,268 ---- while (cookie) { if (cookie->name) len += strlen(cookie->name); ! if (cookie->value) { ! cookievalue = _php3_urlencode(cookie->value, str len (cookie->value)); ! len += strlen(cookievalue); ! } if (cookie->path) len += strlen(cookie->path); if (cookie->domain) *************** *** 280,292 **** efree(dt); } else { /* FIXME: XXX: this is not binary data safe */ ! r = _php3_urlencode(cookie->value, strlen (cooki e->value)); ! sprintf(tempstr, "%s=%s", cookie->name, cookie-> value ? r : ""); ! if (r) efree(r); if (cookie->name) efree(cookie->name); if (cookie->value) efree(cookie->value); cookie->name=NULL; cookie->value=NULL; if (cookie->expires > 0) { strcat(tempstr, "; expires="); dt = php3_std_date(cookie->expires); --- 282,294 ---- efree(dt); } else { /* FIXME: XXX: this is not binary data safe */ ! sprintf(tempstr, "%s=%s", cookie->name, cookie-> value ? cookievalue : ""); if (cookie->name) efree(cookie->name); if (cookie->value) efree(cookie->value); + if (cookievalue) efree(cookievalue); cookie->name=NULL; cookie->value=NULL; + cookievalue=NULL; if (cookie->expires > 0) { strcat(tempstr, "; expires="); dt = php3_std_date(cookie->expires); *************** *** 314,319 **** --- 316,322 ---- if (cookie->path) efree(cookie->path); if (cookie->name) efree(cookie->name); if (cookie->value) efree(cookie->value); + if (cookievalue) efree(cookievalue); efree(cookie); cookie = php3_PopCookieList(); efree(tempstr);