[U-Boot] [PATCH v2] env: throw an error when an empty key is used

Lucian Cojocar cojocar at gmail.com
Sun Apr 28 23:31:57 CEST 2013


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 at gmail.com>
---
Changes for v2:
    - Throw an error instead of silently skip the empty key

 lib/hashtable.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/hashtable.c b/lib/hashtable.c
index 07ebfb2..779580b 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -870,6 +870,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;
-- 
1.7.9.5



More information about the U-Boot mailing list