When setting an environment variable as a space-separated list, and
the list is empty, we must not delete the '=' before the value.
In practice putenv() is likely to discard the invalid string, leaving
the variable unset, but this is not guaranteed.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
buf_len += strlen(&buf[buf_len]);
buf[buf_len++] = ' ';
}
- buf[buf_len - 1] = '\0';
+ if (buf[buf_len - 1] == ' ')
+ buf_len--;
+ buf[buf_len] = '\0';
putenv(buf);
}
buf_len += strlen(&buf[buf_len]);
buf[buf_len++] = ' ';
}
- buf[buf_len - 1] = '\0';
+ if (buf[buf_len - 1] == ' ')
+ buf_len--;
+ buf[buf_len] = '\0';
putenv(buf);
}
buf[buf_len++] = ' ';
}
- buf[buf_len - 1] = '\0';
+ if (buf[buf_len - 1] == ' ')
+ buf_len--;
+ buf[buf_len] = '\0';
putenv(buf);
}
*c++ = ' ';
}
- c[-1] = '\0';
+ if (c[-1] == ' ')
+ c--;
+ *c = '\0';
putenv(buf);
}