Ticket #8878: 0001-Check-if-name-is-NULL-before-calling-strcmp.patch

File 0001-Check-if-name-is-NULL-before-calling-strcmp.patch, 1.4 KB (added by jscipione, 12 years ago)

Check if name is NULL before calling strcmp() on it. This should prevent the KDL here by returning a NULL command instead

  • src/system/kernel/debug/debug_commands.cpp

    From 89b7d27bdded0dbf241dac79a656c3f517cb8498 Mon Sep 17 00:00:00 2001
    From: John Scipione <jscipione@gmail.com>
    Date: Mon, 13 Aug 2012 01:11:27 -0400
    Subject: [PATCH] Check if name is NULL before calling strcmp().
    
    Also some style fixes.
    ---
     src/system/kernel/debug/debug_commands.cpp |   12 ++++++------
     1 file changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/src/system/kernel/debug/debug_commands.cpp b/src/system/kernel/debug/debug_commands.cpp
    index 404d94f..4b66bed 100644
    a b next_debugger_command(debugger_command* command, const char* prefix,  
    234234}
    235235
    236236
    237 debugger_command *
    238 find_debugger_command(const char *name, bool partialMatch, bool& ambiguous)
     237debugger_command*
     238find_debugger_command(const char* name, bool partialMatch, bool &ambiguous)
    239239{
    240     debugger_command *command;
    241 
     240    debugger_command* command = NULL;
    242241    ambiguous = false;
    243242
    244     // search command by full name
     243    if (name == NULL)
     244        return NULL;
    245245
     246    // search command by full name
    246247    for (command = sCommands; command != NULL; command = command->next) {
    247248        if (strcmp(name, command->name) == 0)
    248249            return command;
    249250    }
    250251
    251252    // if it couldn't be found, search for a partial match
    252 
    253253    if (partialMatch) {
    254254        int length = strlen(name);
    255255        command = next_debugger_command(NULL, name, length);