Kernel - Fixed error when checking syscall params
authorJohn Hodge <[email protected]>
Wed, 19 Oct 2011 04:30:47 +0000 (12:30 +0800)
committerJohn Hodge <[email protected]>
Wed, 19 Oct 2011 04:30:47 +0000 (12:30 +0800)
Kernel/lib.c
Kernel/syscalls.c

index 472351c..4d65108 100644 (file)
@@ -854,10 +854,14 @@ int CheckString(const char *String)
 
 /**
  * \brief Check if a sized memory region is valid memory
+ * \return Boolean success
  */
 int CheckMem(const void *Mem, int NumBytes)
 {
        tVAddr  addr = (tVAddr)Mem;
+
+       if( !MM_GetPhysAddr( addr ) )
+               return 0;
        
        if( MM_IsUser( addr ) )
        {
index 7de7b15..9775be3 100644 (file)
@@ -156,16 +156,19 @@ void SyscallHandler(tSyscallRegs *Regs)
                                CHECK_NUM_NONULL( &tmp[i], sizeof(char*) );
                                CHECK_STR_NONULL( tmp[i] );
                        }
+                       if(ret == -1) break;
                        // Check EnvP also
                        // - EnvP can be NULL
                        if( Regs->Arg3 )
                        {
                                tmp = (char**)Regs->Arg3;
-                               //Log("tmp = %p", tmp);
+                               CHECK_NUM_NONULL(tmp, sizeof(char**));
+                               Log("tmp = %p", tmp);
                                for(i=0;tmp[i];i++) {
-                                       CHECK_NUM_NULLOK( &tmp[i], sizeof(char*) );
+                                       CHECK_NUM_NONULL( &tmp[i], sizeof(char*) );
                                        CHECK_STR_NONULL( tmp[i] );
                                }
+                               if(ret == -1) break;
                        }
                }
                LEAVE('s', "Assuming 0");

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