Added sanity checking to kernel vnsprintf
authorJohn Hodge <[email protected]>
Sat, 27 Nov 2010 14:31:22 +0000 (22:31 +0800)
committerJohn Hodge <[email protected]>
Sat, 27 Nov 2010 14:31:22 +0000 (22:31 +0800)
- Also added debug to Video_DrawText in AxWin2

Kernel/lib.c
Usermode/Applications/axwin2_src/WM/video_text.c

index c2c1b58..b9e9734 100644 (file)
@@ -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;
index 897c411..87a72f0 100644 (file)
@@ -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 )

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