Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: devel

[PATCH] Fix memory leak in scdaemon

 

 

GnuPG devel RSS feed   Index | Next | Previous | View Threaded


klaus at flittner

Oct 24, 2009, 9:49 AM

Post #1 of 2 (60 views)
Permalink
[PATCH] Fix memory leak in scdaemon

Hi,

in scd/command.c the buffer allocated by cmd_setdata is never freed.
The attached patch frees the buffer after use and before a second use
of setdata.

Regards
Klaus Flittner
Attachments: scdaemon_fix_memory_leak.patch (1.44 KB)


wk at gnupg

Oct 25, 2009, 8:11 AM

Post #2 of 2 (56 views)
Permalink
Re: [PATCH] Fix memory leak in scdaemon [In reply to]

On Sat, 24 Oct 2009 18:49, klaus[at]flittner.org said:

> in scd/command.c the buffer allocated by cmd_setdata is never freed.
> The attached patch frees the buffer after use and before a second use
> of setdata.

Good catch. The fix is eaven easier than yours; see below.


Shalom-Salam,

Werner


Index: scd/command.c
===================================================================
--- scd/command.c (revision 5172)
+++ scd/command.c (working copy)
@@ -804,6 +804,7 @@
if (!buf)
return out_of_core ();

+ xfree (ctrl->in_data.value);
ctrl->in_data.value = buf;
ctrl->in_data.valuelen = n;
for (p=line, n=0; n < ctrl->in_data.valuelen; p += 2, n++)
Index: scd/scdaemon.c
===================================================================
--- scd/scdaemon.c (revision 5172)
+++ scd/scdaemon.c (working copy)
@@ -892,7 +892,11 @@
static void
scd_deinit_default_ctrl (ctrl_t ctrl)
{
- (void)ctrl;
+ if (!ctrl)
+ return;
+ xfree (ctrl->in_data.value);
+ ctrl->in_data.value = NULL;
+ ctrl->in_data.valuelen = 0;
}


--
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel[at]gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel

GnuPG devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.