Handle 'str' being NULL
This commit is contained in:
parent
ae64ca4671
commit
24c3bfb681
2 changed files with 4 additions and 2 deletions
|
@ -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)) {
|
||||
|
|
|
@ -18,7 +18,8 @@ const char *invalid[] = {
|
|||
"192.168.1.1..",
|
||||
"192.168.1.1a",
|
||||
"555555555555555555555555555555555",
|
||||
""
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue