Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of envvars with more than one = #2204

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/config/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,21 @@ void getEnvVars(void)
// Split key and value using strtok_r
char *saveptr = NULL;
char *key = strtok_r(env_copy, "=", &saveptr);
char *value = strtok_r(NULL, "=", &saveptr);

// Log warning if value is missing
if(value == NULL)
char *value;
if(strlen(*env) <= strlen(key) + 1)
{
log_warn("Environment variable %s has no value, substituting with empty string", key);
value = (char*)"";
}
else
{
// The entire string *after* the key + 1 (for
// the '=') is the value
value = *env + strlen(key) + 1;
}
log_debug(DEBUG_CONFIG, "ENV \"%s\" = \"%s\"", key, value);

// Add to list
struct env_item *new_item = calloc(1, sizeof(struct env_item));
Expand Down
Loading