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 authored and gittup committed Jan 21, 2024
1 parent 63f013c commit 6a92109
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tup/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -5220,7 +5220,13 @@ 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 = malloc(varlen + 1);
if(varname == NULL)
return -1;
strncpy(varname, var, varlen);
varname[varlen] = 0;
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 6a92109

Please sign in to comment.