From: Ilia Alshanetsky Date: Sun, 17 Oct 2004 18:41:30 +0000 (+0000) Subject: MFH: Fixed a bug in addslashes() handling of the '\0' character. X-Git-Tag: php-4.3.10RC1~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db953cd7ffd941a024e88cfd3adcca3d71003f31;p=php MFH: Fixed a bug in addslashes() handling of the '\0' character. --- diff --git a/NEWS b/NEWS index 1ea43b35c6..87cb04a532 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP 4 NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2004, Version 4.3.10 +- Fixed a bug in addslashes() handling of the '\0' character. (Ilia) - Backported Marcus' foreach() speedup patch from PHP 5.x. (Derick) - Fixed potential problems with unserializing invalid serialize data. (Marcus) - Fixed bug #30282 (segfault when using unknown/unsupported diff --git a/ext/standard/string.c b/ext/standard/string.c index 2a243214b0..9fbf0fecd1 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2443,7 +2443,13 @@ PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_f p = str; if (!type) { while (p < e) { - if (php_esc_list[(int)(unsigned char)*p]) { + int c = php_esc_list[(int)(unsigned char)*p]; + if (c == 2) { + *ps++ = '\\'; + *ps++ = '0'; + p++; + continue; + } else if (c) { *ps++ = '\\'; } *ps++ = *p++;