From e4fdcadd8a6eedb1edaabbc85c782b43d4e80fe2 Mon Sep 17 00:00:00 2001 From: Lucian Cojocar Date: Sun, 28 Apr 2013 11:31:57 +0000 Subject: [PATCH] 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 --- lib/hashtable.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.39.5