From: Roy Marples Date: Thu, 27 Feb 2014 11:57:45 +0000 (+0000) Subject: Fix some possible pointer checks. X-Git-Tag: v6.3.1~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04a1918940bf29ae2c29535ad3b8c2396fe5c7aa;p=thirdparty%2Fdhcpcd.git Fix some possible pointer checks. --- diff --git a/dev.h b/dev.h index 55cb290c..a44b6958 100644 --- a/dev.h +++ b/dev.h @@ -51,8 +51,8 @@ int dev_listening(struct dhcpcd_ctx *); int dev_start(struct dhcpcd_ctx *); void dev_stop(struct dhcpcd_ctx *, int); #else -#define dev_initialized(a, b) 1 -#define dev_listening(a) 0 +#define dev_initialized(a, b) (1) +#define dev_listening(a) (0) #define dev_start(a) {} #define dev_stop(a, b) {} #endif diff --git a/dhcp-common.c b/dhcp-common.c index dfda0254..9dab167d 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -44,19 +44,19 @@ struct dhcp_opt * vivso_find(uint16_t iana_en, const void *arg) { - const struct interface *ifp = arg; + const struct interface *ifp; size_t i; struct dhcp_opt *opt; - if (arg) { - ifp = arg; - for (i = 0, opt = ifp->options->vivso_override; - i < ifp->options->vivso_override_len; - i++, opt++) - if (opt->option == iana_en) - return opt; - } - for (i = 0, opt = ifp->ctx->vivso; i < ifp->ctx->vivso_len; i++, opt++) + ifp = arg; + for (i = 0, opt = ifp->options->vivso_override; + i < ifp->options->vivso_override_len; + i++, opt++) + if (opt->option == iana_en) + return opt; + for (i = 0, opt = ifp->ctx->vivso; + i < ifp->ctx->vivso_len; + i++, opt++) if (opt->option == iana_en) return opt; return NULL; diff --git a/script.c b/script.c index a39d25c6..68035bc4 100644 --- a/script.c +++ b/script.c @@ -186,6 +186,8 @@ arraytostr(const char *const *argv, char **s) char *p; size_t len, l; + if (*argv == NULL) + return 0; len = 0; ap = argv; while (*ap) @@ -442,10 +444,12 @@ dumplease: eexit: syslog(LOG_ERR, "%s: %m", __func__); - nenv = env; - while (*nenv) - free(*nenv++); - free(env); + if (env) { + nenv = env; + while (*nenv) + free(*nenv++); + free(env); + } return -1; }