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 e14ef76
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tup/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -5220,7 +5220,11 @@ 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 = strndup(var, varlen);
if(varname == NULL)
return -1;
newenv = getenv(varname);
free(varname);
if(newenv)
newenvlen = strlen(newenv);
ve = envdb_set(var, varlen, newenv, newenvlen, newtent, 1);
Expand Down

0 comments on commit e14ef76

Please sign in to comment.