summaryrefslogtreecommitdiff
path: root/usr.sbin/spamdb
diff options
context:
space:
mode:
authorConstantine A. Murenin <cnst@cvs.openbsd.org>2007-05-31 20:00:17 +0000
committerConstantine A. Murenin <cnst@cvs.openbsd.org>2007-05-31 20:00:17 +0000
commit891716f9dbe3fbea7e4f8f673931597fe480de1c (patch)
tree62a5b25eaa6c844f0d6afc6138af5c233473c735 /usr.sbin/spamdb
parentf0646dd190203a23d2994fe048d94b73b2b4240f (diff)
fix PR 5475: 'empty spamtrap address makes corrupted database'; ok beck@
Diffstat (limited to 'usr.sbin/spamdb')
-rw-r--r--usr.sbin/spamdb/spamdb.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.sbin/spamdb/spamdb.c b/usr.sbin/spamdb/spamdb.c
index 52d495212bb..072c5726d7b 100644
--- a/usr.sbin/spamdb/spamdb.c
+++ b/usr.sbin/spamdb/spamdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamdb.c,v 1.22 2007/02/27 16:22:11 otto Exp $ */
+/* $OpenBSD: spamdb.c,v 1.23 2007/05/31 20:00:16 cnst Exp $ */
/*
* Copyright (c) 2004 Bob Beck. All rights reserved.
@@ -266,7 +266,7 @@ usage(void)
int
main(int argc, char **argv)
{
- int i, ch, action = 0, type = WHITE, r = 0;
+ int i, ch, action = 0, type = WHITE, r = 0, c = 0;
HASHINFO hashinfo;
DB *db;
@@ -312,11 +312,21 @@ main(int argc, char **argv)
return dblist(db);
case 1:
for (i=0; i<argc; i++)
- r += dbupdate(db, argv[i], 1, type);
+ if (argv[i][0] != '\0') {
+ c++;
+ r += dbupdate(db, argv[i], 1, type);
+ }
+ if (c == 0)
+ errx(2, "no addresses specified");
break;
case 2:
for (i=0; i<argc; i++)
- r += dbupdate(db, argv[i], 0, type);
+ if (argv[i][0] != '\0') {
+ c++;
+ r += dbupdate(db, argv[i], 0, type);
+ }
+ if (c == 0)
+ errx(2, "no addresses specified");
break;
default:
errx(-1, "bad action");