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

Marek Behún
2021-10-13T15:46:52Z

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

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

Signed-off-by: Marek Behún <marek.behun@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