]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix some possible pointer checks.
authorRoy Marples <roy@marples.name>
Thu, 27 Feb 2014 11:57:45 +0000 (11:57 +0000)
committerRoy Marples <roy@marples.name>
Thu, 27 Feb 2014 11:57:45 +0000 (11:57 +0000)
dev.h
dhcp-common.c
script.c

diff --git a/dev.h b/dev.h
index 55cb290c18e4c802e65c84fef79d6d50062c28d6..a44b69587c4329d5cf6944e7b27f04ed8f7ac7a3 100644 (file)
--- 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
index dfda0254979565faad4796b368bbdec4a07fb6ca..9dab167d63adaf3ccf0d9bcee90ec92bdd35461c 100644 (file)
 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;
index a39d25c63bfb9b0c2c92e007b02267bc5beaf53e..68035bc45fd28b58f074e7b69e5bec63682ec3bd 100644 (file)
--- 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;
 }