php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13585 nonsense code
Submitted: 2001-10-07 07:40 UTC Modified: 2001-11-18 10:06 UTC
From: s dot esser at e-matters dot de Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.0CVS-2001-10-07 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 - 25 = ?
Subscribe to this entry?

 
 [2001-10-07 07:40 UTC] s dot esser at e-matters dot de
The following piece of code is taken from
SAPI.C/sapi_add_header_ex
it is obvious that this code is nonsense
a) *ptr will point to \0 because someone forgot to increase it (the while loop will never be executed)
b) the second condition in the while loop is redundant
c) the size calculation should be done *after* the while loop

-------------------------
colon_offset = strchr(header_line, ':');
if (colon_offset) {
   *colon_offset = 0;
   if (!STRCASECMP(header_line, "Content-Type")) {
      char *ptr = colon_offset, *mimetype = NULL, *newheader;
      size_t len = header_line_len - (ptr - header_line), newlen;
      while (*ptr == ' ' && *ptr != '\0') {
         ptr++;
      }
      mimetype = estrdup(ptr);
....
--------------------------


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-28 17:15 UTC] sniper@php.net
Could you please explain also where this code fails?
If you have some short example script too, that would
help to see the whole picture.

--Jani

 [2001-11-18 10:06 UTC] sander@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC