summaryrefslogtreecommitdiff
path: root/libexec/spamd
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2007-11-03 19:16:08 +0000
committerBob Beck <beck@cvs.openbsd.org>2007-11-03 19:16:08 +0000
commitbd0fb69c47e27fd2886f0076356340f5df47504a (patch)
tree84d9edbf670e5c60ca5d9da90f6f897f0d16d4dd /libexec/spamd
parent8d47b36de2cf57509703a9cefd4621968f5becd6 (diff)
PR 5621 - spamd doesn't clear the last entry from an empty TRAP list,
noticed and patch from Piotr Sikora <piotr@sikora.nu>
Diffstat (limited to 'libexec/spamd')
-rw-r--r--libexec/spamd/grey.c13
-rw-r--r--libexec/spamd/sdl.c23
-rw-r--r--libexec/spamd/sdl.h3
-rw-r--r--libexec/spamd/spamd.c6
4 files changed, 36 insertions, 9 deletions
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c
index e30333a288a..c23b4b6bc5f 100644
--- a/libexec/spamd/grey.c
+++ b/libexec/spamd/grey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grey.c,v 1.40 2007/08/16 04:42:16 ray Exp $ */
+/* $OpenBSD: grey.c,v 1.41 2007/11/03 19:16:07 beck Exp $ */
/*
* Copyright (c) 2004-2006 Bob Beck. All rights reserved.
@@ -126,11 +126,12 @@ configure_spamd(char **addrs, size_t count, FILE *sdc)
{
size_t i;
- if (count == 0)
- return;
- fprintf(sdc, "%s;%s;", traplist_name, traplist_msg);
- for (i = 0; i < count; i++)
- fprintf(sdc, "%s/32;", addrs[i]);
+ fprintf(sdc, "%s;", traplist_name);
+ if (count != 0) {
+ fprintf(sdc, "%s;", traplist_msg);
+ for (i = 0; i < count; i++)
+ fprintf(sdc, "%s/32;", addrs[i]);
+ }
fprintf(sdc, "\n");
if (fflush(sdc) == EOF)
syslog_r(LOG_DEBUG, &sdata, "configure_spamd: fflush failed (%m)");
diff --git a/libexec/spamd/sdl.c b/libexec/spamd/sdl.c
index 4f88b5133aa..39edaadb402 100644
--- a/libexec/spamd/sdl.c
+++ b/libexec/spamd/sdl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdl.c,v 1.17 2007/09/02 15:19:20 deraadt Exp $ */
+/* $OpenBSD: sdl.c,v 1.18 2007/11/03 19:16:07 beck Exp $ */
/*
* Copyright (c) 2003-2007 Bob Beck. All rights reserved.
@@ -162,6 +162,27 @@ sdl_add(char *sdname, char *sdstring, char ** addrs, int addrc)
return (-1);
}
+void
+sdl_del(char *sdname)
+{
+ int i, idx = -1;
+
+ for (i = 0; i < blu; i++) {
+ if (strcmp(blacklists[i].tag, sdname) == 0) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx != -1) {
+ if (debug > 0)
+ printf("clearing list %s\n", sdname);
+ free(blacklists[idx].string);
+ free(blacklists[idx].addrs);
+ blacklists[idx].string = NULL;
+ blacklists[idx].addrs = NULL;
+ blacklists[idx].naddrs = 0;
+ }
+}
/*
* Return 1 if the addresses a (with mask m) matches address b
diff --git a/libexec/spamd/sdl.h b/libexec/spamd/sdl.h
index 4143c9b68d7..c50370b4177 100644
--- a/libexec/spamd/sdl.h
+++ b/libexec/spamd/sdl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdl.h,v 1.5 2007/03/29 17:39:53 kjell Exp $ */
+/* $OpenBSD: sdl.h,v 1.6 2007/11/03 19:16:07 beck Exp $ */
/*
* Copyright (c) 2003-2007 Bob Beck. All rights reserved.
@@ -54,6 +54,7 @@ struct sdentry {
extern int sdl_add(char *, char *, char **, int);
+extern void sdl_del(char *);
extern struct sdlist **sdl_lookup(struct sdlist *head,
int af, void * src);
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index c13c830bdc1..044caf7f017 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.102 2007/04/13 22:05:43 beck Exp $ */
+/* $OpenBSD: spamd.c,v 1.103 2007/11/03 19:16:07 beck Exp $ */
/*
* Copyright (c) 2002-2007 Bob Beck. All rights reserved.
@@ -192,6 +192,10 @@ parse_configline(char *line)
if (*cp != ';')
goto parse_error;
*cp++ = '\0';
+ if (!*cp) {
+ sdl_del(name);
+ return (0);
+ }
msg = cp;
if (*cp++ != '"')
goto parse_error;