mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
unserialize no longer complaints about unserializing empty-strings (started that just a few days ago)
This commit is contained in:
parent
280f379186
commit
3e307aacc4
1 changed files with 10 additions and 7 deletions
|
@ -347,11 +347,12 @@ int php_var_unserialize(pval **rval, const char **p, const char *max)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
(*p) += 2;
|
(*p) += 2;
|
||||||
str = emalloc(i + 1);
|
|
||||||
if (i > 0) {
|
if (i == 0) {
|
||||||
memcpy(str, *p, i);
|
str = empty_string;
|
||||||
|
} else {
|
||||||
|
str = estrndup(*p,i);
|
||||||
}
|
}
|
||||||
str[i] = 0;
|
|
||||||
(*p) += i + 2;
|
(*p) += i + 2;
|
||||||
(*rval)->type = IS_STRING;
|
(*rval)->type = IS_STRING;
|
||||||
(*rval)->value.str.val = str;
|
(*rval)->value.str.val = str;
|
||||||
|
@ -489,14 +490,16 @@ PHP_FUNCTION(unserialize)
|
||||||
if (ARG_COUNT(ht) != 1 || getParametersEx(1, &buf) == FAILURE) {
|
if (ARG_COUNT(ht) != 1 || getParametersEx(1, &buf) == FAILURE) {
|
||||||
WRONG_PARAM_COUNT;
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*buf)->type == IS_STRING) {
|
if ((*buf)->type == IS_STRING) {
|
||||||
const char *p = (*buf)->value.str.val;
|
const char *p = (*buf)->value.str.val;
|
||||||
const char *q;
|
|
||||||
|
|
||||||
q = p;
|
if ((*buf)->value.str.len == 0) {
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!php_var_unserialize(&return_value, &p, p + (*buf)->value.str.len)) {
|
if (!php_var_unserialize(&return_value, &p, p + (*buf)->value.str.len)) {
|
||||||
php_error(E_NOTICE, "unserialize() failed at offset %d",p-q);
|
php_error(E_NOTICE, "unserialize() failed at offset %d of %d bytes",p-(*buf)->value.str.val,(*buf)->value.str.len);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue