From: John Hodge Date: Sat, 27 Nov 2010 14:31:22 +0000 (+0800) Subject: Added sanity checking to kernel vnsprintf X-Git-Tag: rel0.07~45 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=2b28991acfe9e9014eb14dd47def8e31e4c2b7e4;p=tpg%2Facess2.git Added sanity checking to kernel vnsprintf - Also added debug to Video_DrawText in AxWin2 --- diff --git a/Kernel/lib.c b/Kernel/lib.c index c2c1b588..b9e97344 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -321,6 +321,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) // String - Null Terminated Array case 's': p = va_arg(args, char*); // Get Argument + if( !CheckString(p) ) continue; // Avoid #PFs printString: if(!p) p = "(null)"; len = strlen(p); @@ -331,6 +332,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) case 'C': // Non-Null Terminated Character Array p = va_arg(args, char*); + if( !CheckMem(p, minSize) ) continue; // No #PFs please if(!p) goto printString; while(minSize--) PUTCH(*p++); break; diff --git a/Usermode/Applications/axwin2_src/WM/video_text.c b/Usermode/Applications/axwin2_src/WM/video_text.c index 897c4116..87a72f03 100644 --- a/Usermode/Applications/axwin2_src/WM/video_text.c +++ b/Usermode/Applications/axwin2_src/WM/video_text.c @@ -62,6 +62,9 @@ int Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Col int xOfs = 0; tGlyph *glyph; uint32_t ch = 0; + + _SysDebug("Video_DrawText: (X=%i,Y=%i,W=%i,H=%i,Font=%p,Color=%08x,Text='%s')", + X, Y, W, H, Font, Color, Text); // Check the bounds if(W < 0 || X < 0 || X >= giScreenWidth) return 0; @@ -80,8 +83,7 @@ int Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Col // Find (or load) the glyph glyph = _GetGlyph(Font, ch); - if( glyph ) - continue ; // If not found, just don't render it + if( !glyph ) continue ; // If not found, just don't render it // End render if it will overflow the perscribed range if( xOfs + glyph->TrueWidth > W )