env-util: ensure NUL termination of the replace_env_argv() output array
The output array is allocated with new() and left uninitialized, but a
bare unset "$VAR" token expands to nothing and writes no terminator.
When such a token leads or is the only word, the returned strv is left
without a trailing NULL.
Follow-up for f331434d13
This commit is contained in:
@@ -948,6 +948,8 @@ int replace_env_argv(
|
||||
}
|
||||
|
||||
k += q;
|
||||
/* reallocarray() does not zero-initialize the grown tail, add NUL termination */
|
||||
n[k] = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user