summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLucian Cojocar <cojocar@gmail.com>2013-04-28 11:31:57 +0000
committerTom Rini <trini@ti.com>2013-05-09 17:03:05 -0400
commite4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2 (patch)
treea42c04f7d46f34f2c298c0c8f7443deab400d489 /lib
parentd642c467a071f074b991f9fea0c877c22462c9e9 (diff)
downloadtalos-obmc-uboot-e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2.tar.gz
talos-obmc-uboot-e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2.zip
env: throw an error when an empty key is used
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/hashtable.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 6050dd0829..4cdbc95329 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -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;
OpenPOWER on IntegriCloud