Hi. I added error handling code in write_rotate(). I think that it is better to check tf->logfd before doing truncate()/write() and getting error.
>From 5e24e65d3abfd78e5405b81690d6ada4260cca4e Mon Sep 17 00:00:00 2001 From: Hyejin Kim <[email protected]> Date: Mon, 2 Mar 2015 14:27:00 +0900 Subject: [PATCH] syslogd : check return value when opening file --- toys/pending/syslogd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c index 7fb297f..41d655d 100644 --- a/toys/pending/syslogd.c +++ b/toys/pending/syslogd.c @@ -300,6 +300,10 @@ static int write_rotate(struct logfile *tf, int len) unlink(tf->filename); close(tf->logfd); tf->logfd = open(tf->filename, O_CREAT | O_WRONLY | O_APPEND, 0666); + if (tf->logfd < 0) { + perror_msg("can't open %s", tf->filename); + return -1; + } } ftruncate(tf->logfd, 0); } -- 1.9.1
0001-syslogd-check-return-value-when-opening-file.patch
Description: Binary data
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
