From owner-svn-src-all@freebsd.org Sat Aug 1 01:29:56 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35DBC9AE632; Sat, 1 Aug 2015 01:29:56 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 26C781C20; Sat, 1 Aug 2015 01:29:56 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t711TucW036882; Sat, 1 Aug 2015 01:29:56 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t711TuAv036881; Sat, 1 Aug 2015 01:29:56 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201508010129.t711TuAv036881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 1 Aug 2015 01:29:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286144 - head/usr.bin/wall X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Aug 2015 01:29:56 -0000 Author: pfg Date: Sat Aug 1 01:29:55 2015 New Revision: 286144 URL: https://svnweb.freebsd.org/changeset/base/286144 Log: Buffer overflow in wall(1). Revert r286102 and apply a cleaner fix. Tested for overflows by FORTIFY_SOURCE GSoC (with clang). Suggested by: bde Reviewed by: Oliver Pinter Tested by: Oliver Pinter MFC after: 3 days Modified: head/usr.bin/wall/ttymsg.c Modified: head/usr.bin/wall/ttymsg.c ============================================================================== --- head/usr.bin/wall/ttymsg.c Fri Jul 31 23:40:18 2015 (r286143) +++ head/usr.bin/wall/ttymsg.c Sat Aug 1 01:29:55 2015 (r286144) @@ -62,7 +62,7 @@ ttymsg(struct iovec *iov, int iovcnt, co struct iovec localiov[7]; ssize_t left, wret; int cnt, fd; - char device[MAXNAMLEN] = _PATH_DEV; + char device[MAXNAMLEN]; static char errbuf[1024]; char *p; int forked; @@ -71,8 +71,9 @@ ttymsg(struct iovec *iov, int iovcnt, co if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0]))) return ("too many iov's (change code in wall/ttymsg.c)"); - strlcat(device, line, sizeof(device)); + strlcpy(device, _PATH_DEV, sizeof(device)); p = device + sizeof(_PATH_DEV) - 1; + strlcpy(p, line, sizeof(device) - sizeof(_PATH_DEV)); if (strncmp(p, "pts/", 4) == 0) p += 4; if (strchr(p, '/') != NULL) {