nlopess Fri Dec 12 23:43:18 2008 UTC Modified files: (Branch: PHP_5_3) /php-src configure.in /php-src/main spprintf.c Log: make *printf() functions do not read strings past their specified length (if any) http://cvs.php.net/viewvc.cgi/php-src/configure.in?r1=1.579.2.52.2.77.2.37&r2=1.579.2.52.2.77.2.38&diff_format=u Index: php-src/configure.in diff -u php-src/configure.in:1.579.2.52.2.77.2.37 php-src/configure.in:1.579.2.52.2.77.2.38 --- php-src/configure.in:1.579.2.52.2.77.2.37 Wed Dec 3 21:01:51 2008 +++ php-src/configure.in Fri Dec 12 23:43:17 2008 @@ -1,4 +1,4 @@ -## $Id: configure.in,v 1.579.2.52.2.77.2.37 2008/12/03 21:01:51 johannes Exp $ -*- autoconf -*- +## $Id: configure.in,v 1.579.2.52.2.77.2.38 2008/12/12 23:43:17 nlopess Exp $ -*- autoconf -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -625,6 +625,7 @@ strdup \ strerror \ strftime \ +strnlen \ strptime \ strstr \ strtok_r \ http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.c?r1=1.25.2.2.2.10.2.4&r2=1.25.2.2.2.10.2.5&diff_format=u Index: php-src/main/spprintf.c diff -u php-src/main/spprintf.c:1.25.2.2.2.10.2.4 php-src/main/spprintf.c:1.25.2.2.2.10.2.5 --- php-src/main/spprintf.c:1.25.2.2.2.10.2.4 Thu Feb 7 18:41:35 2008 +++ php-src/main/spprintf.c Fri Dec 12 23:43:18 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.c,v 1.25.2.2.2.10.2.4 2008/02/07 18:41:35 helly Exp $ */ +/* $Id: spprintf.c,v 1.25.2.2.2.10.2.5 2008/12/12 23:43:18 nlopess Exp $ */ /* This is the spprintf implementation. * It has emerged from apache snprintf. See original header: @@ -76,6 +76,7 @@ * SIO stdio-replacement strx_* functions by Panos Tsirigotis * <pa...@alumni.cs.colorado.edu> for xinetd. */ +#define _GNU_SOURCE #include "php.h" #include <stddef.h> @@ -180,6 +181,14 @@ /* }}} */ + +#if !HAVE_STRNLEN +static size_t strnlen(const char *s, size_t maxlen) { + char *r = memchr(s, '\0', maxlen); + return r ? r-s : maxlen; +} +#endif + /* * Do format conversion placing the output in buffer */ @@ -561,9 +570,11 @@ case 'v': s = va_arg(ap, char *); if (s != NULL) { - s_len = strlen(s); - if (adjust_precision && precision < s_len) - s_len = precision; + if (!adjust_precision) { + s_len = strlen(s); + } else { + s_len = strnlen(s, precision); + } } else { s = S_NULL; s_len = S_NULL_LEN;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php