diff options
author | Lucian Cojocar <cojocar@gmail.com> | 2013-04-28 11:31:57 +0000 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2013-05-09 17:03:05 -0400 |
commit | e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2 (patch) | |
tree | a42c04f7d46f34f2c298c0c8f7443deab400d489 /lib/hashtable.c | |
parent | d642c467a071f074b991f9fea0c877c22462c9e9 (diff) | |
download | u-boot-e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2.tar.gz |
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.c | 6 |
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; |