From 6df067c50ad206b9b6049e0668dba60e55c33dab Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Wed, 9 Apr 2014 14:46:13 +0400 Subject: [PATCH] util: Make sure open successed Opening /dev/null may fail, check for ret code. CID 1168167 Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util.c b/util.c index 32860d34a..81f174166 100644 --- a/util.c +++ b/util.c @@ -597,6 +597,10 @@ int cr_daemon(int nochdir, int noclose) int fd; fd = open("/dev/null", O_RDWR); + if (fd < 0) { + pr_perror("Can't open /dev/null"); + return -1; + } dup2(fd, 0); dup2(fd, 1); dup2(fd, 2);