summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2014-04-19 17:21:19 +0000
committergilles <gilles@openbsd.org>2014-04-19 17:21:19 +0000
commita3468cca80fa967a676a78ebb010f9164c5ad45d (patch)
treed6cf6a80b9ab5d6c09e9bb6762d73c42efdce700
parentadd missing strlcpy() check in is_if_in_group() to detect and warn about (diff)
downloadwireguard-openbsd-a3468cca80fa967a676a78ebb010f9164c5ad45d.tar.xz
wireguard-openbsd-a3468cca80fa967a676a78ebb010f9164c5ad45d.zip
add missing strlcpy() checks in create_filter() that would cause smtpd to
fatal at startup if truncation occured and we had enabled filters
-rw-r--r--usr.sbin/smtpd/parse.y14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index 1b0cb4de010..dee50d45e04 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.141 2014/04/19 17:18:58 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.142 2014/04/19 17:21:19 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -2117,8 +2117,16 @@ create_filter(const char *name, const char *path)
}
f = xcalloc(1, sizeof(*f), "create_filter");
- strlcpy(f->name, name, sizeof(f->name));
- strlcpy(f->path, path, sizeof(f->path));
+ if (strlcpy(f->name, name, sizeof(f->name))
+ >= sizeof (f->name)) {
+ yyerror("filter name \"%s\" too long", name);
+ return (NULL);
+ }
+ if (strlcpy(f->path, path, sizeof(f->path))
+ >= sizeof (f->path)) {
+ yyerror("filter path \"%s\" too long", path);
+ return (NULL);
+ }
dict_xset(&conf->sc_filters, name, f);