tool/var: also error when expansion result starts with NUL

Expansions whose output starts with NUL were being expanded to the empty
string, and not being recognised as values that contain a NUL byte, and
should error.

Closes #11694
This commit is contained in:
Emanuele Torre 2023-08-19 18:51:16 +02:00 committed by Daniel Stenberg
parent 1c3fcbdaa9
commit 70f1b540f3
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 35 additions and 2 deletions

View file

@ -307,7 +307,7 @@ ParameterError varexpand(struct GlobalConfig *global,
vlen = curlx_dyn_len(&buf);
}
if(value && *value) {
if(value && vlen > 0) {
/* A variable might contain null bytes. Such bytes cannot be shown
using normal means, this is an error. */
char *nb = memchr(value, '\0', vlen);