fix: strcmp protection with NULL args
This commit is contained in:
parent
0bcc99997a
commit
f65d5ce418
@ -4,6 +4,8 @@ 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];
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "utils.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define ARRAY_SIZE(array) sizeof(array) / sizeof(array[0])
|
|
||||||
|
|
||||||
void color_cmd(char *arg)
|
void color_cmd(char *arg)
|
||||||
{
|
{
|
||||||
uint8_t tmp_color;
|
uint8_t tmp_color;
|
||||||
@ -21,12 +20,10 @@ void color_cmd(char *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp_color = terminal_get_default_color();
|
tmp_color = terminal_get_default_color();
|
||||||
kprintf(KERN_WARNING "Invalid argument\navailable color: ");
|
kprintf(KERN_WARNING "Invalid argument\n");
|
||||||
|
kprintf("Available colors: ");
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
||||||
terminal_set_default_fg_color(i);
|
terminal_set_default_fg_color(i);
|
||||||
// Unai the STRING MERGE argument of kprintf cause me a
|
|
||||||
// cramptissue. I lost all my skibidi aura to fix it but it work
|
|
||||||
// (;
|
|
||||||
kprintf(colors[i]);
|
kprintf(colors[i]);
|
||||||
if (i != ARRAY_SIZE(colors) - 1)
|
if (i != ARRAY_SIZE(colors) - 1)
|
||||||
kprintf(", ");
|
kprintf(", ");
|
||||||
|
Loading…
Reference in New Issue
Block a user