From 9475f78684d3297b3298dbe11b13e6bed572aa68 Mon Sep 17 00:00:00 2001 From: Pete Moore Date: Thu, 18 Jan 2024 14:10:17 +0100 Subject: [PATCH] Issue #483 - fix getenv call to only specify variable name Tup was previously calling getenv("FOO=bar") to retrieve envvar FOO inside tup_db_findenv. This worked on macOS, but not on Linux. Updated to call getenv(varname) instead (e.g. getenv("FOO")). Fixes #483 --- src/tup/db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tup/db.c b/src/tup/db.c index 5ce8a818a..06a2b8085 100644 --- a/src/tup/db.c +++ b/src/tup/db.c @@ -5220,7 +5220,10 @@ int tup_db_findenv(const char *var, int varlen, struct var_entry **ret) newtent = node_insert(env_dtent(), var, varlen, NULL, 0, NULL, 0, TUP_NODE_VAR, INVALID_MTIME, -1); if(!newtent) return -1; - newenv = getenv(var); + char varname[varlen + 1]; + strncpy(&varname[0], var, varlen); + varname[varlen] = '\0'; + newenv = getenv(varname); if(newenv) newenvlen = strlen(newenv); ve = envdb_set(var, varlen, newenv, newenvlen, newtent, 1);