Unix Technical Forum

Patch for memory leak in snmpd/parse.y

This is a discussion on Patch for memory leak in snmpd/parse.y within the mailing.openbsd.tech forums, part of the OpenBSD category; --> It looks like there's a memory leak in parse.y when parsing "listen on addr" lines. Specifically, the memory allocated ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 04:12 AM
Matthew Dempsky
 
Posts: n/a
Default Patch for memory leak in snmpd/parse.y

It looks like there's a memory leak in parse.y when parsing "listen on
addr" lines. Specifically, the memory allocated in host_{v4,v6,dns}
is never freed.

I tested by lowering 'ulimit -d' to a level where unpatched snmpd ran
fine with a file with just "listen on 0.0.0.0" but died on a file with
a million lines of "listen on 0.0.0.0". With the patch below applied,
it ran with the same ulimit using either snmpd.conf.

Index: parse.y
================================================== =================
RCS file: /cvs/src/usr.sbin/snmpd/parse.y,v
retrieving revision 1.11
diff -p -u -r1.11 parse.y
--- parse.y 30 Jan 2008 10:12:45 -0000 1.11
+++ parse.y 23 Feb 2008 04:14:51 -0000
@@ -158,7 +158,7 @@ varset : STRING '=' STRING {

main : LISTEN ON STRING {
struct addresslist al;
- struct address *h;
+ struct address *h, *h2;

TAILQ_INIT(&al);
if (host($3, &al, 1, SNMPD_PORT, NULL, NULL) <= 0) {
@@ -170,6 +170,12 @@ main : LISTEN ON STRING {
h = TAILQ_FIRST(&al);
bcopy(&h->ss, &conf->sc_address.ss, sizeof(*h));
conf->sc_address.port = h->port;
+
+ do {
+ h2 = TAILQ_NEXT(h, entry);
+ free(h);
+ h = h2;
+ } while (h);
}
| READONLY COMMUNITY STRING {
if (strlcpy(conf->sc_rdcommunity, $3,

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:10 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com