From ed11ec794a39d945704b09c6551624f7fb682730 Mon Sep 17 00:00:00 2001 From: 0x35c Date: Fri, 27 Sep 2024 12:07:17 +0200 Subject: [PATCH] fix: nvm strcmp should crash on NULL, color cmd is now protected though --- libbozo/src/string/strcmp.c | 2 -- src/shell/commands/color_cmd.c | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libbozo/src/string/strcmp.c b/libbozo/src/string/strcmp.c index 4456800..616ffd1 100644 --- a/libbozo/src/string/strcmp.c +++ b/libbozo/src/string/strcmp.c @@ -4,8 +4,6 @@ int strcmp(const char *s1, const char *s2) { size_t i = 0; - if (!s1 || !s2) - return -1; while (s1[i] == s2[i] && s1[i] != '\0') i++; return s1[i] - s2[i]; diff --git a/src/shell/commands/color_cmd.c b/src/shell/commands/color_cmd.c index 049fd04..b22545a 100644 --- a/src/shell/commands/color_cmd.c +++ b/src/shell/commands/color_cmd.c @@ -13,12 +13,16 @@ void color_cmd(char *arg) "DARK_GREY", "LIGHT_BLUE", "LIGHT_GREEN", "LIGHT_CYAN", "LIGHT_RED", "LIGHT_MAGENTA", "LIGHT_YELLOW", "WHITE", }; + + if (!arg) + goto invalid; for (size_t i = 0; i < ARRAY_SIZE(colors); i++) { if (strcmp(colors[i], arg) == 0) { terminal_change_default_fg_color(i); return; } } +invalid: tmp_color = terminal_get_default_color(); kprintf(KERN_WARNING "Invalid argument\n"); kprintf("Available colors: ");