Skip to content

Commit

Permalink
Issue #483 - fix getenv call to only specify variable name
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petemoore committed Jan 18, 2024
1 parent 8739d02 commit 9475f78
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/tup/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9475f78

Please sign in to comment.