summaryrefslogtreecommitdiff
path: root/libexec/spamd
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2004-03-05 00:31:06 +0000
committerBob Beck <beck@cvs.openbsd.org>2004-03-05 00:31:06 +0000
commit1dd26808779078e6ef2ca9a2ff384c2b99f3dac5 (patch)
treef9c18eee97aeabd657c07a400006a5645bc43a21 /libexec/spamd
parent20a7fc0cb2d2965df42833156f80b2ca04559187 (diff)
Fix really dumb memory leak that would have long runnign large whitelist
servers having their pf update process growing massive as it leaked huge tracks of whitelist. ok millert@
Diffstat (limited to 'libexec/spamd')
-rw-r--r--libexec/spamd/grey.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c
index 5aeeb01b1d3..85987b8eeb3 100644
--- a/libexec/spamd/grey.c
+++ b/libexec/spamd/grey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grey.c,v 1.7 2004/03/01 17:03:10 otto Exp $ */
+/* $OpenBSD: grey.c,v 1.8 2004/03/05 00:31:05 beck Exp $ */
/*
* Copyright (c) 2004 Bob Beck. All rights reserved.
@@ -106,16 +106,26 @@ configure_pf(char **addrs, int count)
return(-1);
}
for (i = 0; i < count; i++)
- if (addrs[i] != NULL) {
+ if (addrs[i] != NULL)
fprintf(pf, "%s/32\n", addrs[i]);
- free(addrs[i]);
- addrs[i] = NULL;
- }
fclose(pf);
waitpid(pid, NULL, 0);
return(0);
}
+void
+freewhiteaddr(void)
+{
+ int i;
+
+ if (whitelist != NULL)
+ for (i = 0; i < whitecount; i++) {
+ free(whitelist[i]);
+ whitelist[i] = NULL;
+ }
+ whitecount = 0;
+}
+
/* validate, then add to list of addrs to whitelist */
int
addwhiteaddr(char *addr)
@@ -233,11 +243,13 @@ greyscan(char *dbname)
db->sync(db, 0);
db->close(db);
db = NULL;
+ freewhiteaddr();
return(0);
bad:
db->sync(db, 0);
db->close(db);
db = NULL;
+ freewhiteaddr();
return(-1);
}