diff --git a/libreborn/src/util/exec.c b/libreborn/src/util/exec.c index 82be982..3083fd1 100644 --- a/libreborn/src/util/exec.c +++ b/libreborn/src/util/exec.c @@ -95,10 +95,12 @@ char *run_command(const char *const command[], int *return_code) { // Read stdout close(output_pipe[1]); char *output = NULL; - char c; +#define BUFFER_SIZE 1024 + char buf[BUFFER_SIZE]; int bytes_read = 0; - while ((bytes_read = read(output_pipe[0], (void *) &c, 1)) > 0) { - string_append(&output, "%c", c); + while ((bytes_read = read(output_pipe[0], (void *) buf, BUFFER_SIZE - 1 /* Account For NULL-Terminator */)) > 0) { + buf[bytes_read] = '\0'; + string_append(&output, "%s", buf); } close(output_pipe[0]);