]> granicus.if.org Git - php/commitdiff
Fixed a possible invalid read when string is not null terminated
authorIlia Alshanetsky <iliaa@php.net>
Sun, 1 Feb 2009 19:42:48 +0000 (19:42 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 1 Feb 2009 19:42:48 +0000 (19:42 +0000)
main/spprintf.c

index 704230d33d8fb6d1737e025c74785f546193c263..aeecc6ca705783e9b4ed66e33249317a77649d24 100644 (file)
@@ -547,9 +547,11 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
                                case 'v':
                                        s = va_arg(ap, char *);
                                        if (s != NULL) {
-                                               s_len = strlen(s);
-                                               if (adjust_precision && precision < s_len)
+                                               if (adjust_precision && precision) {
                                                        s_len = precision;
+                                               } else {
+                                                       s_len = strlen(s);
+                                               }
                                        } else {
                                                s = S_NULL;
                                                s_len = S_NULL_LEN;