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

Marek Behún kabel at kernel.org
Sun Oct 17 17:36:33 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>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
 cmd/nvedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 5b1d4c2448..8d53579d92 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -708,7 +708,7 @@ char *from_env(const char *envvar)
 
 static const char *env_match(const char *p, const char *s1)
 {
-	if (s1 == NULL)
+	if (s1 == NULL || *s1 == '\0')
 		return NULL;
 
 	while (*s1 == *p++)
-- 
2.32.0



More information about the U-Boot mailing list