From: gilles Date: Sat, 19 Apr 2014 17:21:19 +0000 (+0000) Subject: add missing strlcpy() checks in create_filter() that would cause smtpd to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a3468cca80fa967a676a78ebb010f9164c5ad45d;p=openbsd add missing strlcpy() checks in create_filter() that would cause smtpd to fatal at startup if truncation occured and we had enabled filters --- 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);