]> git.sur5r.net Git - u-boot/commitdiff
env: throw an error when an empty key is used
authorLucian Cojocar <cojocar@gmail.com>
Sun, 28 Apr 2013 11:31:57 +0000 (11:31 +0000)
committerTom Rini <trini@ti.com>
Thu, 9 May 2013 21:03:05 +0000 (17:03 -0400)
If the environment contains an entry like "=value" "\0" we should throw
an error when parsing the environment. Otherwise, U-Boot will enter in
an infinite loop.

Signed-off-by: Lucian Cojocar <cojocar@gmail.com>
lib/hashtable.c

index 6050dd0829f9ac3ce3bc399d1cc7e9428af3afa0..4cdbc95329c0d9d5892d81eed39254fc13796f2a 100644 (file)
@@ -901,6 +901,12 @@ int himport_r(struct hsearch_data *htab,
                *sp++ = '\0';   /* terminate value */
                ++dp;
 
+               if (*name == 0) {
+                       debug("INSERT: unable to use an empty key\n");
+                       __set_errno(EINVAL);
+                       return 0;
+               }
+
                /* Skip variables which are not supposed to be processed */
                if (!drop_var_from_set(name, nvars, localvars))
                        continue;