Kernel/libc - Replace invalid '%C' strings with "(inval)"
authorJohn Hodge <[email protected]>
Sun, 9 Feb 2014 14:35:35 +0000 (22:35 +0800)
committerJohn Hodge <[email protected]>
Sun, 9 Feb 2014 14:35:35 +0000 (22:35 +0800)
KernelLand/Kernel/libc.c

index d42e524..2e08a17 100644 (file)
@@ -391,13 +391,20 @@ int vsnprintf(char *__s, const size_t __maxlen, const char *__format, va_list ar
                
                case 'C':       // Non-Null Terminated Character Array
                        p = va_arg(args, char*);
-                       if( !CheckMem(p, minSize) )     continue;       // No #PFs please
+                       if( !CheckMem(p, minSize) ) {
+                               p = "(inval)";
+                               goto printString;
+                       }
                        if(!p)  goto printString;
                        while(minSize--) {
                                if(*p == '\0') {
                                        PUTCH('\\');
                                        PUTCH('0');
                                }
+                               else if(*p == '\\') {
+                                       PUTCH('\\');
+                                       PUTCH('\\');
+                               }
                                else {
                                        PUTCH(*p);
                                }

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