From: John Hodge Date: Mon, 18 Aug 2014 23:51:10 +0000 (+0800) Subject: Kernel/libc - Print address of invalid strings X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=71402d670b1de4f4db7c1768e92ac1f723b51d9a;p=tpg%2Facess2.git Kernel/libc - Print address of invalid strings --- diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index fba30479..572184d9 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -381,7 +381,7 @@ int vsnprintf(char *__s, const size_t __maxlen, const char *__format, va_list ar break; } p = va_arg(args, char*); // Get Argument - if( !p || !CheckString(p) ) p = "(inval)"; // Avoid #PFs + if( p && !CheckString(p) ) goto invalString; // Avoid #PFs printString: if(!p) p = "(null)"; len = strlen(p); @@ -389,6 +389,20 @@ int vsnprintf(char *__s, const size_t __maxlen, const char *__format, va_list ar while(*p && precision--) { PUTCH(*p); p++;} if( bPadLeft ) while(len++ < minSize) PUTCH(pad); break; + invalString: + PUTCH('(');PUTCH('i');PUTCH('n');PUTCH('v');PUTCH('a'); PUTCH('l');PUTCH(':'); + PUTCH('*');PUTCH('0');PUTCH('x'); + val = (tVAddr)p; + for( len = BITS/4; len -- && ((val>>(len*4))&15) == 0; ) + ; + len ++; + if( len == 0 ) + PUTCH( '0' ); + else + while( len -- ) + PUTCH( cUCDIGITS[ (val>>(len*4))&15 ] ); + PUTCH(')'); + break; case 'C': // Non-Null Terminated Character Array p = va_arg(args, char*);