com php-src: fixed unpack(): ext/standard/pack.c

From: Date: Wed, 16 Oct 2013 10:09:44 +0000
Subject: com php-src: fixed unpack(): ext/standard/pack.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-73483@lists.php.net to get a copy of this message
Commit: 5b6f0092f4d0b33dd80cdd093585df9829736786 Author: Anatol Belski <ab@php.net> Wed, 21 Aug 2013 03:54:13 -0700 Parents: d7d84804e6213d39eab25e8b83df9bfdd3d966f8 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5b6f0092f4d0b33dd80cdd093585df9829736786 Log: fixed unpack() Changed paths: M ext/standard/pack.c Diff: diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 9f6a9e5..3bf7e08 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -529,9 +529,9 @@ static long php_unpack(char *data, zend_str_size_int size, int issigned, int *ma PHP_FUNCTION(unpack) { char *format, *input, *formatarg, *inputarg; - int formatlen; zend_str_size_int formatarg_len, inputarg_len; - int inputpos, inputlen, i; + zend_str_size_int formatlen, inputpos, inputlen; + int i; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &formatarg, &formatarg_len, &inputarg, &inputarg_len) == FAILURE) { @@ -551,8 +551,8 @@ PHP_FUNCTION(unpack) char c; int arg = 1, argb; char *name; - zend_str_size_int namelen; - zend_str_size_int size=0; + int namelen; + int size=0; /* Handle format arguments if any */ if (formatlen > 0) { @@ -673,7 +673,7 @@ PHP_FUNCTION(unpack) inputpos = 0; } - if ((inputpos + size) <= inputlen) { + if ((size >=0 && (inputpos + size) <= inputlen) || (size < 0 && -size <= (inputlen - inputpos))) { switch ((int) type) { case 'a': { /* a will not strip any trailing whitespace or null padding */ @@ -920,8 +920,10 @@ PHP_FUNCTION(unpack) } } - formatlen--; /* Skip '/' separator, does no harm if inputlen == 0 */ - format++; + if (formatlen > 0) { + formatlen--; /* Skip '/' separator, does no harm if inputlen == 0 */ + format++; + } } } /* }}} */

« previous php.cvs (#73483) next »