X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=KernelLand%2FKernel%2Flibc.c;h=572184d9bd5a94a05342526ce4f84f763e03861d;hb=9c4eedf4893f851bd1ba60ce541c8d098a9ef7f7;hp=c065e1ed8908dc59a9e2645ad5201e14cfe11bae;hpb=3d1d6dcdd09ad5c4e05daea338b42a736b13b1f3;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index c065e1ed..572184d9 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -74,6 +74,7 @@ EXPORT(CheckMem); // === CODE === // - Import userland stroi.c file #define _LIB_H_ +#define _SysDebug(f,v...) Log_Debug("libc", f ,## v) #include "../../Usermode/Libraries/libc.so_src/strtoi.c" int ParseInt(const char *string, int *Val) @@ -380,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); @@ -388,13 +389,40 @@ 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*); - if( !CheckMem(p, minSize) ) continue; // No #PFs please + if( !CheckMem(p, minSize) ) { + p = "(inval)"; + goto printString; + } if(!p) goto printString; while(minSize--) { - PUTCH(*p); + if(*p == '\0') { + PUTCH('\\'); + PUTCH('0'); + } + else if(*p == '\\') { + PUTCH('\\'); + PUTCH('\\'); + } + else { + PUTCH(*p); + } p ++; } break;