From db953cd7ffd941a024e88cfd3adcca3d71003f31 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 17 Oct 2004 18:41:30 +0000 Subject: [PATCH] MFH: Fixed a bug in addslashes() handling of the '\0' character. --- NEWS | 1 + ext/standard/string.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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++; -- 2.50.1