From 52b046c636bd04ef70e6ad73ef7b844d99a1417b Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 13 Apr 2015 17:03:23 -0500 Subject: [PATCH] Fix off-by-one in daemon detach --- lib/roken/detach.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/roken/detach.c b/lib/roken/detach.c index e9fbafc39..626e1e608 100644 --- a/lib/roken/detach.c +++ b/lib/roken/detach.c @@ -159,7 +159,7 @@ roken_detach_prep(int argc, char **argv, char *special_arg) ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL roken_detach_finish(const char *dir, int daemon_child_fd) { - char buf[1]; + char buf[1] = ""; ssize_t bytes; int fd; @@ -187,7 +187,6 @@ roken_detach_finish(const char *dir, int daemon_child_fd) err(1, "failed to chdir to /"); #endif - buf[1] = 0; do { bytes = write(pipefds[1], buf, sizeof(buf)); } while (bytes == -1 && errno == EINTR);