[PATCH v2 05/13] env: Don't match empty variable name in env_match()

Marek Behún kabel at kernel.org
Wed Oct 13 17:45:49 CEST 2021


From: Marek Behún <marek.behun at nic.cz>

Do we really allow zero-length variable name? I guess not.

Signed-off-by: Marek Behún <marek.behun at nic.cz>
---
 cmd/nvedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 742e0924af..e2e8a38b5d 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -708,7 +708,7 @@ char *from_env(const char *envvar)
 
 static int env_match(uchar *s1, int i2)
 {
-	if (s1 == NULL)
+	if (s1 == NULL || *s1 == '\0')
 		return -1;
 
 	while (*s1 == env_get_char(i2++))
-- 
2.32.0



More information about the U-Boot mailing list