cvs: php-src(PHP_5_2) / NEWS /ext/standard scanf.c

From: Date: Fri, 04 Aug 2006 11:50:15 +0000
Subject: cvs: php-src(PHP_5_2) / NEWS /ext/standard scanf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-39757@lists.php.net to get a copy of this message
tony2001 Fri Aug 4 11:50:15 2006 UTC Modified files: (Branch: PHP_5_2) /php-src NEWS /php-src/ext/standard scanf.c Log: MFH: fix #38322 (reading past array in sscanf() leads to arbitary code execution) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.181&r2=1.2027.2.547.2.182&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.181 php-src/NEWS:1.2027.2.547.2.182 --- php-src/NEWS:1.2027.2.547.2.181 Thu Aug 3 14:49:11 2006 +++ php-src/NEWS Fri Aug 4 11:50:15 2006 @@ -30,6 +30,8 @@ - Fixed phpinfo() cutoff of variables at \0. (Ilia) - Fixed a bug in the filter extension that prevented magic_quotes_gpc from being applied when RAW filter is used. (Ilia) +- Fixed bug #38322 (reading past array in sscanf() leads to arbitary code + execution). (Tony) - Fixed bug #38303 (spl_autoload_register() supress all errors silently). (Ilia) - Fixed bug #38289 (segfault in session_decode() when _SESSION is NULL). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.31.2.2&r2=1.31.2.2.2.1&diff_format=u Index: php-src/ext/standard/scanf.c diff -u php-src/ext/standard/scanf.c:1.31.2.2 php-src/ext/standard/scanf.c:1.31.2.2.2.1 --- php-src/ext/standard/scanf.c:1.31.2.2 Sun Jan 1 12:50:15 2006 +++ php-src/ext/standard/scanf.c Fri Aug 4 11:50:15 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: scanf.c,v 1.31.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: scanf.c,v 1.31.2.2.2.1 2006/08/04 11:50:15 tony2001 Exp $ */ /* scanf.c -- @@ -732,7 +732,7 @@ if (*end == '$') { format = end+1; ch = format++; - objIndex = varStart + value; + objIndex = varStart + value - 1; } } @@ -762,7 +762,9 @@ switch (*ch) { case 'n': if (!(flags & SCAN_SUPPRESS)) { - if (numVars) { + if (numVars && objIndex >= argCount) { + break; + } else if (numVars) { zend_uint refcount; current = args[objIndex++]; @@ -888,7 +890,9 @@ } } if (!(flags & SCAN_SUPPRESS)) { - if (numVars) { + if (numVars && objIndex >= argCount) { + break; + } else if (numVars) { zend_uint refcount; current = args[objIndex++]; @@ -932,7 +936,9 @@ goto done; } if (!(flags & SCAN_SUPPRESS)) { - if (numVars) { + if (numVars && objIndex >= argCount) { + break; + } else if (numVars) { current = args[objIndex++]; zval_dtor( *current ); ZVAL_STRINGL( *current, string, end-string, 1); @@ -1089,7 +1095,9 @@ value = (int) (*fn)(buf, NULL, base); if ((flags & SCAN_UNSIGNED) && (value < 0)) { sprintf(buf, "%u", value); /* INTL: ISO digit */ - if (numVars) { + if (numVars && objIndex >= argCount) { + break; + } else if (numVars) { /* change passed value type to string */ current = args[objIndex++]; convert_to_string( *current ); @@ -1098,7 +1106,9 @@ add_index_string(*return_value, objIndex++, buf, 1); } } else { - if (numVars) { + if (numVars && objIndex >= argCount) { + break; + } else if (numVars) { current = args[objIndex++]; convert_to_long( *current ); Z_LVAL(**current) = value; @@ -1206,7 +1216,9 @@ double dvalue; *end = '\0'; dvalue = zend_strtod(buf, NULL); - if (numVars) { + if (numVars && objIndex >= argCount) { + break; + } else if (numVars) { current = args[objIndex++]; convert_to_double( *current ); Z_DVAL_PP( current ) = dvalue;

« previous php.cvs (#39757) next »