Kernel/libc - Fixed infinite loop in vsnprintf
authorJohn Hodge (sonata) <[email protected]>
Fri, 30 Nov 2012 06:49:37 +0000 (14:49 +0800)
committerJohn Hodge (sonata) <[email protected]>
Fri, 30 Nov 2012 06:49:37 +0000 (14:49 +0800)
KernelLand/Kernel/libc.c

index 8674650..67ce9b2 100644 (file)
@@ -363,7 +363,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
                        if(!p)          p = "(null)";
                        len = strlen(p);
                        if( !bPadLeft ) while(len++ < minSize)  PUTCH(pad);
-                       while(*p && precision--)        PUTCH(*p++);
+                       while(*p && precision--) { PUTCH(*p); p++;} 
                        if( bPadLeft )  while(len++ < minSize)  PUTCH(pad);
                        break;
                
@@ -371,7 +371,10 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
                        p = va_arg(args, char*);
                        if( !CheckMem(p, minSize) )     continue;       // No #PFs please
                        if(!p)  goto printString;
-                       while(minSize--)        PUTCH(*p++);
+                       while(minSize--) {
+                               PUTCH(*p);
+                               p ++;
+                       }
                        break;
                
                // Single Character

UCC git Repository :: git.ucc.asn.au