php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #660 Long cookies containing characters that need encoding
Submitted: 1998-08-18 05:21 UTC Modified: 1998-08-18 08:48 UTC
From: drew at elysium dot demon dot co dot uk Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 3.0.3 OS: Redhat Linux 4.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: drew at elysium dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [1998-08-18 05:21 UTC] drew at elysium dot demon dot co dot uk
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);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-08-18 08:48 UTC] rasmus
Applied - Thanks for catching that.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC