]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
options: Fix prior
authorRoy Marples <roy@marples.name>
Tue, 7 Feb 2023 17:02:29 +0000 (17:02 +0000)
committerRoy Marples <roy@marples.name>
Tue, 7 Feb 2023 17:04:44 +0000 (17:04 +0000)
For #184.

src/if-options.c

index b1a4c3c5dc76891242d35a2eb8cacd2a8ae4e1ca..3a50cd08a52a61cb67392002808bb463b68eacfa 100644 (file)
@@ -190,9 +190,13 @@ add_environ(char ***array, const char *value, int uniq)
                return NULL;
        }
        *p++ = '\0';
+       l = strlen(match);
 
        while (list && list[i]) {
-               if (match && strcmp(list[i], match) == 0) {
+               /* We know that it must contain '=' due to the above test */
+               size_t listl = (size_t)(strchr(list[i], '=') - list[i]);
+
+               if (l == listl && strncmp(list[i], match, l) == 0) {
                        if (uniq) {
                                n = strdup(value);
                                if (n == NULL) {