From owner-svn-src-stable-11@freebsd.org Wed Jul 5 15:31:43 2017 Return-Path: Delivered-To: svn-src-stable-11@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 3AEFDDAD9F4; Wed, 5 Jul 2017 15:31:43 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 06C1084AFE; Wed, 5 Jul 2017 15:31:42 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v65FVglH065961; Wed, 5 Jul 2017 15:31:42 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v65FVgW2065960; Wed, 5 Jul 2017 15:31:42 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201707051531.v65FVgW2065960@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 5 Jul 2017 15:31:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r320676 - stable/11/usr.sbin/bootparamd/bootparamd X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/usr.sbin/bootparamd/bootparamd X-SVN-Commit-Revision: 320676 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jul 2017 15:31:43 -0000 Author: asomers Date: Wed Jul 5 15:31:42 2017 New Revision: 320676 URL: https://svnweb.freebsd.org/changeset/base/320676 Log: MFC r318790, r319336 r318790: Fix a buffer overflow in bootparamd(8) If /etc/bootparams contains a line with an excessively long pathname, and a client asks for that path, then bootparamd will overflow a buffer and crash while parsing that line. This is not remotely exploitable since it requires a malformed /etc/bootparams file. Reported by: Coverity CID: 1305954 Sponsored by: Spectra Logic Corp r319336: Fix uninitialized variable in bootparamd.c Restore line that was accidentally deleted in change 318790 Reported by: Coverity CID: 1375855 X-MFC-With: 318790 Sponsored by: Spectra Logic Corp Modified: stable/11/usr.sbin/bootparamd/bootparamd/bootparamd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/bootparamd/bootparamd/bootparamd.c ============================================================================== --- stable/11/usr.sbin/bootparamd/bootparamd/bootparamd.c Wed Jul 5 15:23:30 2017 (r320675) +++ stable/11/usr.sbin/bootparamd/bootparamd/bootparamd.c Wed Jul 5 15:31:42 2017 (r320676) @@ -199,7 +199,10 @@ int blen; int ch, pch, fid_len, res = 0; int match = 0; - char info[MAX_FILEID + MAX_PATH_LEN+MAX_MACHINE_NAME + 3]; +#define INFOLEN 1343 + _Static_assert(INFOLEN >= MAX_FILEID + MAX_PATH_LEN+MAX_MACHINE_NAME + 3, + "INFOLEN isn't large enough"); + char info[INFOLEN + 1]; bpf = fopen(bootpfile, "r"); if ( ! bpf ) @@ -252,7 +255,9 @@ int blen; if (match) { fid_len = strlen(fileid); - while ( ! res && (fscanf(bpf,"%s", info)) > 0) { /* read a string */ +#define AS_FORMAT(d) "%" #d "s" +#define REXPAND(d) AS_FORMAT(d) /* Force another preprocessor expansion */ + while ( ! res && (fscanf(bpf, REXPAND(INFOLEN), info)) > 0) { ch = getc(bpf); /* and a character */ if ( *info != '#' ) { /* Comment ? */ if (! strncmp(info, fileid, fid_len) && *(info + fid_len) == '=') {