소스 검색

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>
Lucian Cojocar 12 년 전
부모
커밋
e4fdcadd8a
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      lib/hashtable.c

+ 6 - 0
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;