summaryrefslogtreecommitdiff
path: root/lib/hashtable.c
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/hashtable.c
parentd642c467a071f074b991f9fea0c877c22462c9e9 (diff)
downloadu-boot-imx-e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2.zip
u-boot-imx-e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2.tar.gz
u-boot-imx-e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2.tar.bz2
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/hashtable.c')
-rw-r--r--lib/hashtable.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 6050dd0..4cdbc95 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;