|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-04-15 20:08 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Calling money_format with an apparently correct format <?php setlocale (LC_MONETARY, 'en_US'); echo money_format ('%#.2n', 1000); ?> causes PHP to hang (tested with 4.3.1 and 5-dev). Apparently, strfmon() returns -1 (errno is 22, indicating an invalid parameter) even though the format should theoretically be correct. The -1 is not trapped in strings.c, resulting in a huge string full of binary data being returned. Here's my suggested patch, returning false on an error from strfmon(). Index: string.c =================================================================== RCS file: /repository/php4/ext/standard/string.c,v retrieving revision 1.374 diff -u -r1.374 string.c --- string.c 13 Apr 2003 22:59:19 -0000 1.374 +++ string.c 15 Apr 2003 12:30:14 -0000 @@ -46,6 +46,7 @@ #include "php_globals.h" #include "basic_functions.h" #include "php_smart_str.h" +#include "zend_operators.h" #ifdef ZTS #include "TSRM.h" #endif @@ -4372,7 +4373,11 @@ str_len = format_len + 1024; str = emalloc(str_len); - str_len = strfmon(str, str_len, format, value); + str_len = strfmon(str, str_len, format, value); + + if (str_len == -1) + RETURN_FALSE; + str[str_len] = 0; RETURN_STRINGL(erealloc(str, str_len + 1), str_len, 0);