summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-22 14:00:21 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-22 14:00:21 +0930
commit37965b33eeb202773dc70c4546d0b050b8e717b5 (patch)
treee2de90d802575124ac374ab2fb9e652306efeafc
parent24e5ddb143fb5e79112649472258f5da67cc7362 (diff)
ccanlint: fix output for async commands.
Previously, it was always "", since we left the nul terminator at the start.
-rw-r--r--tools/ccanlint/async.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/ccanlint/async.c b/tools/ccanlint/async.c
index 9c7a442e..5c2c4da7 100644
--- a/tools/ccanlint/async.c
+++ b/tools/ccanlint/async.c
@@ -148,14 +148,16 @@ static void reap_output(void)
tlist_for_each_safe(&running, c, next, list) {
if (FD_ISSET(c->output_fd, &in)) {
int old_len, len;
+ /* This length includes nul terminator! */
old_len = talloc_array_length(c->output);
c->output = talloc_realloc(c, c->output, char,
old_len + 1024);
- len = read(c->output_fd, c->output + old_len, 1024);
+ len = read(c->output_fd, c->output + old_len - 1, 1024);
if (len < 0)
err(1, "Reading from async command");
c->output = talloc_realloc(c, c->output, char,
old_len + len);
+ c->output[old_len + len - 1] = '\0';
if (len == 0) {
struct rusage ru;
wait4(c->pid, &c->status, 0, &ru);