From 6d177801c0f72a0fcd4ff3320b42c66d94c0274a Mon Sep 17 00:00:00 2001 From: gilles Date: Sat, 19 Apr 2014 17:18:58 +0000 Subject: [PATCH] add missing strlcpy() check in is_if_in_group() to detect and warn about the truncation rather than failing the ioctl() call that follows. --- usr.sbin/smtpd/parse.y | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index afac7c71478..1b0cb4de010 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.140 2014/04/19 17:12:02 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.141 2014/04/19 17:18:58 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -2075,7 +2075,9 @@ is_if_in_group(const char *ifname, const char *groupname) err(1, "socket"); memset(&ifgr, 0, sizeof(ifgr)); - strlcpy(ifgr.ifgr_name, ifname, IFNAMSIZ); + if (strlcpy(ifgr.ifgr_name, ifname, IFNAMSIZ) >= IFNAMSIZ) + errx(1, "interface name too large"); + if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) { if (errno == EINVAL || errno == ENOTTY) goto end; -- 2.20.1