[Toybox] Patch : syslogd

김혜진 hj8296 at gmail.com
Sun Mar 1 22:18:38 PST 2015


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 <hj8296 at gmail.com>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20150302/3b29262f/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-syslogd-check-return-value-when-opening-file.patch
Type: application/octet-stream
Size: 809 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20150302/3b29262f/attachment-0004.obj>


More information about the Toybox mailing list