fix: nvm strcmp should crash on NULL, color cmd is now protected though
This commit is contained in:
parent
f65d5ce418
commit
ed11ec794a
@ -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];
|
||||
|
@ -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: ");
|
||||
|
Loading…
Reference in New Issue
Block a user