From 325d28effc5f5df169c3a9d9b4c9fa9bb7d5472d Mon Sep 17 00:00:00 2001 From: gilles Date: Sat, 19 Apr 2014 17:23:19 +0000 Subject: [PATCH] add missing strlcpy() check in create_filter_chain() that would cause smtpd to fatal at startup if truncation occured and we had enabled filters (void) cast a strlcpy() that cannot truncate --- usr.sbin/smtpd/parse.y | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index dee50d45e04..b80ee85dd8e 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.142 2014/04/19 17:21:19 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.143 2014/04/19 17:23:19 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -2143,7 +2143,11 @@ create_filter_chain(const char *name) return (NULL); } f = xcalloc(1, sizeof(*f), "create_filter_chain"); - strlcpy(f->name, name, sizeof(f->name)); + if (strlcpy(f->name, name, sizeof(f->name)) >= + sizeof(f->name)) { + yyerror("filter chain name \"%s\" too long", name); + return (NULL); + } f->chain = 1; dict_xset(&conf->sc_filters, name, f); @@ -2172,7 +2176,7 @@ extend_filter_chain(struct filter *f, const char *name) for (i = 0; i < MAX_FILTER_PER_CHAIN; i++) { if (f->filters[i][0] == '\0') { - strlcpy(f->filters[i], name, sizeof(f->filters[i])); + (void)strlcpy(f->filters[i], name, sizeof(f->filters[i])); return (1); } } -- 2.20.1