env: throw an error when an empty key is used
[platform/kernel/u-boot.git] / lib / hashtable.c
index 6050dd0..4cdbc95 100644 (file)
@@ -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;