|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-02-19 11:36 UTC] mt at debian dot org
Description: ------------ goto-cc (part of the cbmc package) reported that php_url_decode is defined with size_t parameter and return types in ext/standard/url.c, but main/streams/memory.c for some reason runs its own declaration, using int. For all systems with sizeof(int)!=sizeof(size_t), the sizeof(size_t)-sizeof(int) bytes will be taken from somewhere on the stack or an uninitialised register. Thus decoding may have some arbitrary behaviour, where a crash is likely the best possible case - it's an out-of-bounds memory access. Best, Michael Patchesmemory.patch (last revision 2016-02-19 12:03 UTC by ondrej@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
It seems I cannot add a patch to a security-tagged bug report (authentication error), hence posting it here: diff -urN a/main/streams/memory.c b/main/streams/memory.c --- a/main/streams/memory.c 2016-02-19 02:17:42.000000000 +0000 +++ b/main/streams/memory.c 2016-02-19 02:18:41.000000000 +0000 @@ -21,7 +21,7 @@ #include "php.h" #include "ext/standard/base64.h" -PHPAPI int php_url_decode(char *str, int len); +PHPAPI size_t php_url_decode(char *str, size_t len); /* Memory streams use a dynamic memory buffer to emulate a stream. * You can use php_stream_memory_open to create a readonly stream @@ -729,7 +729,7 @@ ilen = (int)ZSTR_LEN(base64_comma); } else { comma = estrndup(comma, dlen); - dlen = php_url_decode(comma, (int)dlen); + dlen = php_url_decode(comma, dlen); ilen = (int)dlen; }