aboutsummaryrefslogtreecommitdiff
path: root/src/Program.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Program.c')
-rw-r--r--src/Program.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Program.c b/src/Program.c
index 480f403..731a20e 100644
--- a/src/Program.c
+++ b/src/Program.c
@@ -39,7 +39,7 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void
char buffer[2048];
for(;;) {
- ssize_t bytes_read = read(fd[READ_END], buffer, sizeof(buffer));
+ ssize_t bytes_read = read(fd[READ_END], buffer, sizeof(buffer) - 1);
if(bytes_read == 0) {
break;
} else if(bytes_read == -1) {
@@ -49,6 +49,7 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void
goto cleanup;
}
+ buffer[bytes_read] = '\0';
if(output_callback && output_callback(buffer, bytes_read, userdata) != 0)
break;
}