summaryrefslogtreecommitdiff
path: root/libexec/spamlogd
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-03-01 17:03:11 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-03-01 17:03:11 +0000
commit5e10182ce2fa51d51f190e0eafd4b0d1a2358da9 (patch)
treeedcdb8411aaebfbd3ab2d0770612def8eba26141 /libexec/spamlogd
parent0597ddfc164be74586215c528a55cb929c83b0fd (diff)
uset inet_pton(3) instead of home grown address validator; some other cleanup
ok beck@
Diffstat (limited to 'libexec/spamlogd')
-rw-r--r--libexec/spamlogd/spamlogd.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/libexec/spamlogd/spamlogd.c b/libexec/spamlogd/spamlogd.c
index a25676caccc..07a7e118d65 100644
--- a/libexec/spamlogd/spamlogd.c
+++ b/libexec/spamlogd/spamlogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamlogd.c,v 1.3 2004/02/27 18:25:49 beck Exp $ */
+/* $OpenBSD: spamlogd.c,v 1.4 2004/03/01 17:03:10 otto Exp $ */
/*
* Copyright (c) 2004 Bob Beck. All rights reserved.
@@ -52,20 +52,6 @@ char **whitelist;
int inbound; /* do we only whitelist inbound smtp? */
int pfdev;
-/* borrowed from dhartmei.. */
-static int
-address_valid_v4(const char *a)
-{
- if (!*a)
- return (0);
- while (*a)
- if ((*a >= '0' && *a <= '9') || *a == '.')
- a++;
- else
- return (0);
- return (1);
-}
-
int
dbupdate(char *dbname, char *ip)
{
@@ -75,13 +61,14 @@ dbupdate(char *dbname, char *ip)
struct gdata gd;
time_t now;
int r;
+ struct in_addr ia;
now = time(NULL);
memset(&btreeinfo, 0, sizeof(btreeinfo));
db = dbopen(dbname, O_EXLOCK|O_RDWR, 0600, DB_BTREE, &btreeinfo);
if (db == NULL)
return(-1);
- if (!address_valid_v4(ip)) {
+ if (inet_pton(AF_INET, ip, &ia) != 1) {
syslog_r(LOG_NOTICE, &sdata, "invalid ip address %s", ip);
goto bad;
}
@@ -276,10 +263,8 @@ main(int argc, char **argv)
if (cp != NULL)
dbupdate(PATH_SPAMD_DB, cp);
- if (lbuf != NULL) {
- free(lbuf);
- lbuf = NULL;
- }
+ free(lbuf);
+ lbuf = NULL;
}
exit(0);
}