~ubuntu-branches/debian/squeeze/cpulimit/squeeze

« back to all changes in this revision

Viewing changes to debian/patches/04_opendir_leak.patch

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann
  • Date: 2010-01-13 18:57:37 UTC
  • Revision ID: james.westby@ubuntu.com-20100113185737-ngi4duas4z6d2jr1
Tags: 1.1-13
* Add patch 04_opendir_leak.patch: cpulimit was leaking opendir() handles.
  Thanks to Johan Walles for the bug report and the patch (closes: #564517).
* debian/copyright: update formatting, fix reference to common-licenses, and
  add stanza for debian/*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Author: Johan Walles <johan.walles@gmail.com>
 
2
Bug-Debian: http://bugs.debian.org/564517
 
3
Description: Each time cpulimit finds a process to limit, it does a goto
 
4
 past the call to closedir(). Plug that leak.
 
5
Forwarded: yes
 
6
Origin: vendor, cf. bug
 
7
Reviewed-By: gregor herrmann <gregoa@debian.org>
 
8
Last-Update: 2010-01-11
 
9
 
 
10
--- a/cpulimit.c
 
11
+++ b/cpulimit.c
 
12
@@ -98,6 +98,10 @@
 
13
                                //pid detected
 
14
                                if (kill(pid,SIGSTOP)==0 &&  kill(pid,SIGCONT)==0) {
 
15
                                        //process is ok!
 
16
+                                       if (closedir(dip) == -1) {
 
17
+                                               perror("closedir");
 
18
+                                               return -1;
 
19
+                                       }
 
20
                                        goto done;
 
21
                                }
 
22
                                else {
 
23
@@ -188,6 +192,10 @@
 
24
                                        if (found==1) {
 
25
                                                if (kill(pid,SIGSTOP)==0 &&  kill(pid,SIGCONT)==0) {
 
26
                                                        //process is ok!
 
27
+                                                       if (closedir(dip) == -1) {
 
28
+                                                               perror("closedir");
 
29
+                                                               return -1;
 
30
+                                                       }
 
31
                                                        goto done;
 
32
                                                }
 
33
                                                else {