summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-05-12 23:15:59 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-05-12 23:15:59 +0000
commit7b1b1772f0a242d0975581e9225723f262a7a5f7 (patch)
tree7a059dcd3f7ceeb44f54c9451049fc596ea63576 /src
parentf42bff4c9dc8374205e3581df1ce72fca972dcd1 (diff)
downloads6-rc-7b1b1772f0a242d0975581e9225723f262a7a5f7.tar.xz
bugfixes: fd leak in s6-rc-oneshot-run, and missing coe in s6rc_lock
Diffstat (limited to 'src')
-rw-r--r--src/libs6rc/s6rc_lock.c7
-rw-r--r--src/s6-rc/s6-rc-oneshot-run.c3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libs6rc/s6rc_lock.c b/src/libs6rc/s6rc_lock.c
index 2a623d0..43b60bb 100644
--- a/src/libs6rc/s6rc_lock.c
+++ b/src/libs6rc/s6rc_lock.c
@@ -28,6 +28,7 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int
memcpy(lfn + llen, "/lock", 6) ;
lfd = open_create(lfn) ;
if (lfd < 0) return 0 ;
+ if (coe(lfd) < 0) { e = errno ; goto lerr ; }
if ((lwhat > 1 ? lockex(lfd, blocking) : locksh(lfd, blocking)) < 0) { e = errno ; goto lerr ; }
}
@@ -41,7 +42,11 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int
if (cfd < 0)
if (cwhat > 1 || errno != EROFS) { e = errno ; goto lerr ; }
else cfd = -errno ;
- else if ((cwhat > 1 ? lockex(cfd, blocking) : locksh(cfd, blocking)) < 0) { e = errno ; goto cerr ; }
+ else
+ {
+ if (coe(cfd) < 0) { e = errno ; goto cerr ; }
+ if ((cwhat > 1 ? lockex(cfd, blocking) : locksh(cfd, blocking)) < 0) { e = errno ; goto cerr ; }
+ }
}
if (lwhat) *llfd = lfd ;
diff --git a/src/s6-rc/s6-rc-oneshot-run.c b/src/s6-rc/s6-rc-oneshot-run.c
index 6973ab9..9b48a33 100644
--- a/src/s6-rc/s6-rc-oneshot-run.c
+++ b/src/s6-rc/s6-rc-oneshot-run.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <strings.h>
#include <stdint.h>
+#include <unistd.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -86,7 +87,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
r = s6rc_db_read(fdcompiled, &db) ;
if (r < 0) strerr_diefu3sys(111, "read ", compiled, "/db") ;
if (!r) strerr_dief3x(4, "invalid service database in ", compiled, "/db") ;
-
+ close(fdcompiled) ;
/* Run the script */