[systemd-commits] 2 commits - src/tmpfiles.c src/util.c

Lennart Poettering lennart at kemper.freedesktop.org
Mon Oct 10 13:33:49 PDT 2011


 src/tmpfiles.c |    1 +
 src/util.c     |    9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 678abaf91e2308f02fb679c2dc2679a3b6a5b8be
Author: Thomas Jarosch <thomas.jarosch at intra2net.com>
Date:   Wed Oct 5 22:31:41 2011 +0200

    util: fix close() call on wrong variable
    
    Detected by "cppcheck" (actually it detected a file descriptor leak)

diff --git a/src/util.c b/src/util.c
index 7977ee4..e46606d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2307,8 +2307,10 @@ int chvt(int vt) {
                         0
                 };
 
-                if (ioctl(fd, TIOCLINUX, tiocl) < 0)
-                        return -errno;
+                if (ioctl(fd, TIOCLINUX, tiocl) < 0) {
+                        r = -errno;
+                        goto fail;
+                }
 
                 vt = tiocl[0] <= 0 ? 1 : tiocl[0];
         }
@@ -2316,7 +2318,8 @@ int chvt(int vt) {
         if (ioctl(fd, VT_ACTIVATE, vt) < 0)
                 r = -errno;
 
-        close_nointr_nofail(r);
+fail:
+        close_nointr_nofail(fd);
         return r;
 }
 

commit 10d975f54c88223fb8762a226fd011ec3f30f2eb
Author: Thomas Jarosch <thomas.jarosch at intra2net.com>
Date:   Wed Oct 5 22:30:49 2011 +0200

    tmpfiles: fix file descriptor leak
    
    Detected by "cppcheck"

diff --git a/src/tmpfiles.c b/src/tmpfiles.c
index a6b8f85..21bf44d 100644
--- a/src/tmpfiles.c
+++ b/src/tmpfiles.c
@@ -157,6 +157,7 @@ static void load_unix_sockets(void) {
                 }
         }
 
+        fclose(f);
         return;
 
 fail:



More information about the systemd-commits mailing list