Commit e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2
Committed by
Tom Rini
1 parent
d642c467a0
Exists in
master
and in
53 other branches
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>
Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff
lib/hashtable.c
... | ... | @@ -901,6 +901,12 @@ |
901 | 901 | *sp++ = '\0'; /* terminate value */ |
902 | 902 | ++dp; |
903 | 903 | |
904 | + if (*name == 0) { | |
905 | + debug("INSERT: unable to use an empty key\n"); | |
906 | + __set_errno(EINVAL); | |
907 | + return 0; | |
908 | + } | |
909 | + | |
904 | 910 | /* Skip variables which are not supposed to be processed */ |
905 | 911 | if (!drop_var_from_set(name, nvars, localvars)) |
906 | 912 | continue; |