|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-02-27 21:40 UTC] jon+php at unequivocal dot co dot uk
Dear morons,
Please observe the following two lines from the 'fix' you have posted for your file-upload incompetence:
loc = (char *) memchr(ptr, '\n', rem)+1;
if (!loc) {
There's a bug in this code. Can you see what it is? Hint: the 'if' expression will never evaluate true. Well, that's assuming the first line doesn't crash since it invokes undefined behaviour.
Hint #2: the whole routine (not just those 2 lines) is still completely and utterly broken as of revision 1.71.2.2. It is riddled with code that reads beyond the end of the buffer.
Hint #3: yet again, you need to follow-up to your Bugtraq posting with a message saying 'Not only were we too stupid to write the code right in the first place, we were too stupid to fix it right too. Please ignore our previous patch. Please use this new one, which will probably be wrong also.'
HTH, HAND.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 19:00:02 2025 UTC |
How about this patch: --- main/rfc1867.c.orig Thu Feb 28 14:08:25 2002 +++ main/rfc1867.c Thu Feb 28 14:33:03 2002 @@ -163,20 +163,28 @@ SAFE_RETURN; } /* some other headerfield found, skip it */ - loc = (char *) memchr(ptr, '\n', rem)+1; + loc = (char *) memchr(ptr, '\n', rem); if (!loc) { /* broken */ php_error(E_WARNING, "File Upload Mime headers garbled ptr: [%c%c%c%c%c]", *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4)); SAFE_RETURN; } + else + { + loc++; + } while (*loc == ' ' || *loc == '\t') { /* other field is folded, skip it */ - loc = (char *) memchr(loc, '\n', rem-(loc-ptr))+1; + loc = (char *) memchr(loc, '\n', rem-(loc-ptr)); if (!loc) { /* broken */ php_error(E_WARNING, "File Upload Mime headers garbled ptr: [%c%c%c%c%c]", *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4)); SAFE_RETURN; } + else + { + loc++; + } } rem -= (loc - ptr); ptr = loc; @@ -232,6 +240,10 @@ * pre 4.0.6 code here */ loc2 = memchr(loc + 1, '\n', rem); + if (!loc2) { + php_error(E_WARNING, "File Upload Mime headers - no newline"); + SAFE_RETURN; + } rem -= (loc2 - ptr) + 1; ptr = loc2 + 1; /* is_arr_upload is true when name of file upload field