]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix a memory error.
authorRoy Marples <roy@marples.name>
Wed, 26 Nov 2014 15:34:14 +0000 (15:34 +0000)
committerRoy Marples <roy@marples.name>
Wed, 26 Nov 2014 15:34:14 +0000 (15:34 +0000)
script.c

index 0f6b360e7f708f03488988650702726dd89114ca..31e80fabd52a7a81baa41e930d83efaf97d42d18 100644 (file)
--- a/script.c
+++ b/script.c
@@ -288,8 +288,8 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
                elen = 13;
 
 #define EMALLOC(i, l) if ((env[(i)] = malloc((l))) == NULL) goto eexit;
-       /* Make our env */
-       env = calloc(1, sizeof(char *) * (elen + 1));
+       /* Make our env + space for profile, wireless and debug */
+       env = calloc(1, sizeof(char *) * (elen + 3 + 1));
        if (env == NULL)
                goto eexit;
        e = strlen("interface") + strlen(ifp->name) + 2;
@@ -378,7 +378,7 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
                snprintf(env[elen++], e, "syslog_debug=true");
        }
        if (*ifp->profile) {
-               e = strlen("profile=") + strlen(ifp->profile) + 2;
+               e = strlen("profile=") + strlen(ifp->profile) + 1;
                EMALLOC(elen, e);
                snprintf(env[elen++], e, "profile=%s", ifp->profile);
        }