Bug 753709 - Fix fd leak in KLockFile
Summary: Fix fd leak in KLockFile
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: kdelibs
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Than Ngo
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 754405 (view as bug list)
Depends On:
Blocks: 754405
TreeView+ depends on / blocked
 
Reported: 2011-11-14 09:04 UTC by Andreas Schwab
Modified: 2011-11-17 23:39 UTC (History)
9 users (show)

Fixed In Version: kdelibs-4.6.5-8.fc14
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-11-17 23:27:31 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Andreas Schwab 2011-11-14 09:04:01 UTC
From 865e5fa4108bb3f470b9424ec34dc573d97e2473 Mon Sep 17 00:00:00 2001
From: David Faure <faure>
Date: Wed, 24 Aug 2011 10:29:09 +0200
Subject: [PATCH] Fix fd leak in KLockFile

Didn't expect that after open(fd), QFile::close doesn't close the fd :)
---
 kdecore/io/klockfile_unix.cpp |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/kdecore/io/klockfile_unix.cpp b/kdecore/io/klockfile_unix.cpp
index fa2eda4..93e92e2 100644
--- a/kdecore/io/klockfile_unix.cpp
+++ b/kdecore/io/klockfile_unix.cpp
@@ -78,6 +78,7 @@ public:
         : staleTime(30), // 30 seconds
           isLocked(false),
           linkCountSupport(true),
+          mustCloseFd(false),
           m_pid(-1),
           m_componentData(c)
     {
@@ -102,6 +103,7 @@ public:
     int staleTime;
     bool isLocked;
     bool linkCountSupport;
+    bool mustCloseFd;
     QTime staleTimer;
     KDE_struct_stat statBuf;
     int m_pid;
@@ -285,7 +287,10 @@ KLockFile::LockResult KLockFile::Private::lockFileOExcl(KDE_struct_stat &st_buf)
     if (!m_file.open(fd, QIODevice::WriteOnly)) {
         return LockError;
     }
+    mustCloseFd = true;
     writeIntoLockFile(m_file, m_componentData);
+
+    // stat to get the modification time
     const int result = KDE_lstat(QFile::encodeName(m_fileName), &st_buf);
     if (result != 0)
         return KLockFile::LockError;
@@ -476,6 +481,10 @@ void KLockFile::unlock()
   if (d->isLocked)
   {
      ::unlink(QFile::encodeName(d->m_fileName));
+      if (d->mustCloseFd) {
+         close(d->m_file.handle());
+         d->mustCloseFd = false;
+     }
      d->m_file.close();
      d->m_pid = -1;
      d->isLocked = false;
-- 
1.7.6.4

Comment 1 Fedora Update System 2011-11-16 15:58:56 UTC
kdelibs-4.6.5-8.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/kdelibs-4.6.5-8.fc15

Comment 2 Fedora Update System 2011-11-16 15:59:46 UTC
kdelibs-4.6.5-8.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/kdelibs-4.6.5-8.fc14

Comment 3 Kevin Kofler 2011-11-17 15:20:38 UTC
*** Bug 754405 has been marked as a duplicate of this bug. ***

Comment 4 Fedora Update System 2011-11-17 23:27:31 UTC
kdelibs-4.6.5-8.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 5 Fedora Update System 2011-11-17 23:39:43 UTC
kdelibs-4.6.5-8.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.