From a3468cca80fa967a676a78ebb010f9164c5ad45d Mon Sep 17 00:00:00 2001 From: gilles Date: Sat, 19 Apr 2014 17:21:19 +0000 Subject: [PATCH] add missing strlcpy() checks in create_filter() that would cause smtpd to fatal at startup if truncation occured and we had enabled filters --- usr.sbin/smtpd/parse.y | 14 +++++++++++--- 1 file 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 @@ -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); -- 2.20.1