summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-09-19 13:00:00 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-09-19 13:00:00 +0000
commit77f0227e43737e3cb7db9c4f8f5ec9857c781e47 (patch)
treee5627b941cc58cf17353201ecd888b501cfff96c
parentaa5714ec7e0ecebc2738c4a8b8b3d60fce518728 (diff)
expandnodes must be bzero()'d before parsing to be sure there is no bogus
data left on return, since the RB compare functions uses memcmp(). While there, remove all calls to bzero() before alias_parse(). ok gilles@
-rw-r--r--usr.sbin/smtpd/aliases.c13
-rw-r--r--usr.sbin/smtpd/forward.c3
-rw-r--r--usr.sbin/smtpd/makemap.c3
-rw-r--r--usr.sbin/smtpd/map_db.c4
-rw-r--r--usr.sbin/smtpd/map_static.c4
-rw-r--r--usr.sbin/smtpd/map_stdio.c4
6 files changed, 15 insertions, 16 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c
index a5a975a7829..b991532d195 100644
--- a/usr.sbin/smtpd/aliases.c
+++ b/usr.sbin/smtpd/aliases.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aliases.c,v 1.52 2012/09/19 12:45:04 eric Exp $ */
+/* $OpenBSD: aliases.c,v 1.53 2012/09/19 12:59:59 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -155,7 +155,6 @@ aliases_expand_include(struct expandtree *expandtree, const char *filename)
continue;
}
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, line)) {
log_warnx("could not parse include entry \"%s\".", line);
}
@@ -214,6 +213,8 @@ alias_is_filter(struct expandnode *alias, const char *line, size_t len)
static int
alias_is_username(struct expandnode *alias, const char *line, size_t len)
{
+ bzero(alias, sizeof *alias);
+
if (strlcpy(alias->u.user, line,
sizeof(alias->u.user)) >= sizeof(alias->u.user))
return 0;
@@ -234,6 +235,8 @@ alias_is_address(struct expandnode *alias, const char *line, size_t len)
{
char *domain;
+ bzero(alias, sizeof *alias);
+
if (len < 3) /* x@y */
return 0;
@@ -273,6 +276,8 @@ alias_is_address(struct expandnode *alias, const char *line, size_t len)
static int
alias_is_filename(struct expandnode *alias, const char *line, size_t len)
{
+ bzero(alias, sizeof *alias);
+
if (*line != '/')
return 0;
@@ -287,7 +292,9 @@ static int
alias_is_include(struct expandnode *alias, const char *line, size_t len)
{
size_t skip;
-
+
+ bzero(alias, sizeof *alias);
+
if (strncasecmp(":include:", line, 9) == 0)
skip = 9;
else if (strncasecmp("include:", line, 8) == 0)
diff --git a/usr.sbin/smtpd/forward.c b/usr.sbin/smtpd/forward.c
index 9df0a51e7e2..c6a46fd57b5 100644
--- a/usr.sbin/smtpd/forward.c
+++ b/usr.sbin/smtpd/forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: forward.c,v 1.26 2012/09/19 12:45:04 eric Exp $ */
+/* $OpenBSD: forward.c,v 1.27 2012/09/19 12:59:59 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -82,7 +82,6 @@ forwards_get(int fd, struct expandtree *expandtree, char *as_user)
buf = cp;
cp = p;
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, buf)) {
log_debug("bad entry in ~/.forward");
continue;
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c
index 11defcb0fe2..0451c40eac0 100644
--- a/usr.sbin/smtpd/makemap.c
+++ b/usr.sbin/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.35 2012/09/19 12:45:04 eric Exp $ */
+/* $OpenBSD: makemap.c,v 1.36 2012/09/19 12:59:59 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -370,7 +370,6 @@ make_aliases(DBT *val, char *text)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof(struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;
}
diff --git a/usr.sbin/smtpd/map_db.c b/usr.sbin/smtpd/map_db.c
index c48d7078f4b..9daccbf97d6 100644
--- a/usr.sbin/smtpd/map_db.c
+++ b/usr.sbin/smtpd/map_db.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: map_db.c,v 1.6 2012/09/19 12:45:04 eric Exp $ */
+/* $OpenBSD: map_db.c,v 1.7 2012/09/19 12:59:59 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -229,7 +229,6 @@ map_db_alias(char *key, char *line, size_t len)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;
@@ -274,7 +273,6 @@ map_db_virtual(char *key, char *line, size_t len)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;
diff --git a/usr.sbin/smtpd/map_static.c b/usr.sbin/smtpd/map_static.c
index 078e53460ed..759198a4998 100644
--- a/usr.sbin/smtpd/map_static.c
+++ b/usr.sbin/smtpd/map_static.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: map_static.c,v 1.3 2012/09/19 12:45:04 eric Exp $ */
+/* $OpenBSD: map_static.c,v 1.4 2012/09/19 12:59:59 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@openbsd.org>
@@ -201,7 +201,6 @@ map_static_alias(char *key, char *line, size_t len)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;
@@ -246,7 +245,6 @@ map_static_virtual(char *key, char *line, size_t len)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;
diff --git a/usr.sbin/smtpd/map_stdio.c b/usr.sbin/smtpd/map_stdio.c
index 40e98ccf846..770dac50b15 100644
--- a/usr.sbin/smtpd/map_stdio.c
+++ b/usr.sbin/smtpd/map_stdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: map_stdio.c,v 1.6 2012/09/19 12:45:04 eric Exp $ */
+/* $OpenBSD: map_stdio.c,v 1.7 2012/09/19 12:59:59 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -264,7 +264,6 @@ map_stdio_alias(char *key, char *line, size_t len)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;
@@ -309,7 +308,6 @@ map_stdio_virtual(char *key, char *line, size_t len)
while (subrcpt < endp && isspace((int)*endp))
*endp-- = '\0';
- bzero(&xn, sizeof (struct expandnode));
if (! alias_parse(&xn, subrcpt))
goto error;