From: Pierre-Alexandre Meyer Date: Wed, 25 Mar 2009 05:23:46 +0000 (-0700) Subject: hdt: Fix NULL dereference in core X-Git-Tag: syslinux-3.80-pre1~65 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3161f91283dcdd1486c1e22523e2fbb7259f76a;p=platform%2Fupstream%2Fsyslinux.git hdt: Fix NULL dereference in core Impact: Bug fixing; add debug info There was a NULL dereference in the CLI core for modes that doesn't implement a set of modules (show, set, ...). Also, check the command name on the `command' variable, not the raw line. Misc.: add debug info. Signed-off-by: Pierre-Alexandre Meyer --- diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index f98ab76..c964d58 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -325,27 +325,31 @@ static void exec_command(char *line, * pci> show device 12 * hdt> set mode dmi */ - if (!strncmp(line, CLI_SHOW, sizeof(CLI_SHOW) - 1)) { + if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) { + dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW); find_cli_callback_descr(module, current_mode->show_modules, ¤t_module); /* Execute the callback */ if (current_module != NULL) return current_module->exec(argc, argv, hardware); else { - if (current_mode->show_modules->default_callback != NULL) + if (current_mode->show_modules != NULL && + current_mode->show_modules->default_callback != NULL) return current_mode->show_modules ->default_callback(argc, argv, hardware); } - } else if (!strncmp(line, CLI_SET, sizeof(CLI_SET) - 1)) { + } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) { + dprintf("CLI DEBUG: %s command detected\n", CLI_SET); find_cli_callback_descr(module, current_mode->set_modules, ¤t_module); /* Execute the callback */ if (current_module != NULL) return current_module->exec(argc, argv, hardware); else { - if (current_mode->set_modules->default_callback != NULL) + if (current_mode->set_modules != NULL && + current_mode->set_modules->default_callback != NULL) return current_mode->set_modules ->default_callback(argc, argv,