[shell] Fix a potential null-pointer derefence because we didn't check that cmd wasn't null

This commit is contained in:
Kevin Lange 2011-03-25 19:49:44 -05:00
parent cdd9aaab7c
commit c3395de72f
2 changed files with 5 additions and 0 deletions

View File

@ -249,6 +249,10 @@ page_fault(
int reserved = r->err_code & 0x8;
int id = r->err_code & 0x10;
if (faulting_address == 0) {
kprintf("Null pointer dereference in the kernel.\n");
}
kprintf("Page fault! (p:%d,rw:%d,user:%d,res:%d,id:%d) at 0x%x\n", present, rw, user, reserved, id, faulting_address);
HALT_AND_CATCH_FIRE("Page fault");
}

View File

@ -43,6 +43,7 @@ start_shell() {
char * save;
pch = strtok_r(buffer," ",&save);
cmd = pch;
if (!cmd) { continue; }
char * argv[1024]; /* Command tokens (space-separated elements) */
int tokenid = 0;
while (pch != NULL) {