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;
|
size_t i = 0;
|
||||||
|
|
||||||
if (!s1 || !s2)
|
|
||||||
return -1;
|
|
||||||
while (s1[i] == s2[i] && s1[i] != '\0')
|
while (s1[i] == s2[i] && s1[i] != '\0')
|
||||||
i++;
|
i++;
|
||||||
return s1[i] - s2[i];
|
return s1[i] - s2[i];
|
||||||
|
@ -13,12 +13,16 @@ void color_cmd(char *arg)
|
|||||||
"DARK_GREY", "LIGHT_BLUE", "LIGHT_GREEN", "LIGHT_CYAN",
|
"DARK_GREY", "LIGHT_BLUE", "LIGHT_GREEN", "LIGHT_CYAN",
|
||||||
"LIGHT_RED", "LIGHT_MAGENTA", "LIGHT_YELLOW", "WHITE",
|
"LIGHT_RED", "LIGHT_MAGENTA", "LIGHT_YELLOW", "WHITE",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!arg)
|
||||||
|
goto invalid;
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
||||||
if (strcmp(colors[i], arg) == 0) {
|
if (strcmp(colors[i], arg) == 0) {
|
||||||
terminal_change_default_fg_color(i);
|
terminal_change_default_fg_color(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
invalid:
|
||||||
tmp_color = terminal_get_default_color();
|
tmp_color = terminal_get_default_color();
|
||||||
kprintf(KERN_WARNING "Invalid argument\n");
|
kprintf(KERN_WARNING "Invalid argument\n");
|
||||||
kprintf("Available colors: ");
|
kprintf("Available colors: ");
|
||||||
|
Loading…
Reference in New Issue
Block a user