Skip to content

Commit

Permalink
Issue gittup#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 gittup#483
  • Loading branch information
petemoore committed Jan 18, 2024
1 parent 8739d02 commit 0c78e8a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tup/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -5220,7 +5220,12 @@ 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 0c78e8a

Please sign in to comment.