From: Roy Marples Date: Tue, 14 Jan 2014 11:13:36 +0000 (+0000) Subject: Fix some possible NULL dereferences, CID 1153963. X-Git-Tag: v6.2.1~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4dd50184cd70839f1baac37ba90feee83e6b7e57;p=thirdparty%2Fdhcpcd.git Fix some possible NULL dereferences, CID 1153963. --- diff --git a/if-options.c b/if-options.c index fc35f763..30c146f0 100644 --- a/if-options.c +++ b/if-options.c @@ -525,6 +525,8 @@ static char * strwhite(const char *s) { + if (s == NULL) + return NULL; while (*s != ' ' && *s != '\t') { if (*s == '\0') return NULL; @@ -537,6 +539,8 @@ static char * strskipwhite(const char *s) { + if (s == NULL) + return NULL; while (*s == ' ' || *s == '\t') { if (*s == '\0') return NULL; @@ -1053,10 +1057,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg) } ifo->arping = naddr; ifo->arping[ifo->arping_len++] = addr.s_addr; - if (fp) - arg = strskipwhite(fp); - else - arg = NULL; + arg = strskipwhite(fp); } break; case O_DESTINATION: @@ -1283,7 +1284,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg) u = 0; else { fp = strwhite(arg); - if (!fp) { + if (fp == NULL) { syslog(LOG_ERR, "invalid syntax: %s", arg); return -1; } @@ -1295,6 +1296,10 @@ parse_option(struct if_options *ifo, int opt, const char *arg) return -1; } arg = strskipwhite(fp); + if (arg == NULL) { + syslog(LOG_ERR, "invalid syntax"); + return -1; + } } /* type */ fp = strwhite(arg);