Unverified Commit b02d1aee by Christian Brauner Committed by Stéphane Graber

utils: do not write to 0 sized buffer

parent 3874902c
...@@ -2330,9 +2330,11 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args) ...@@ -2330,9 +2330,11 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args)
/* close the write-end of the pipe */ /* close the write-end of the pipe */
close(pipefd[1]); close(pipefd[1]);
bytes = read(pipefd[0], buf, (buf_size > 0) ? (buf_size - 1) : 0); if (buf && buf_size > 0) {
if (bytes > 0) bytes = read(pipefd[0], buf, buf_size - 1);
buf[bytes - 1] = '\0'; if (bytes > 0)
buf[bytes - 1] = '\0';
}
fret = wait_for_pid(child); fret = wait_for_pid(child);
/* close the read-end of the pipe */ /* close the read-end of the pipe */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment