Handle 'str' being NULL

This commit is contained in:
0x1eef 2023-08-25 18:25:20 -03:00
parent ae64ca4671
commit 24c3bfb681
2 changed files with 4 additions and 2 deletions

View file

@ -19,8 +19,9 @@ isinetaddr(const char *str)
{
char buf[4];
int i = 0, j = 0, k = 0;
size_t len = strnlen(str, 16);
size_t len;
len = str == NULL ? 0 : strnlen(str, 16);
for(size_t l = 0; l < len; l++) {
if (str[l] == '.') {
if (inrange(buf)) {

View file

@ -18,7 +18,8 @@ const char *invalid[] = {
"192.168.1.1..",
"192.168.1.1a",
"555555555555555555555555555555555",
""
"",
NULL
};
int