From owner-svn-src-stable-10@freebsd.org Sat Feb 20 10:56:47 2016 Return-Path: Delivered-To: svn-src-stable-10@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 CB5CAAAFA9C; Sat, 20 Feb 2016 10:56:47 +0000 (UTC) (envelope-from smh@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 94C5DA3B; Sat, 20 Feb 2016 10:56:47 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1KAukTF078957; Sat, 20 Feb 2016 10:56:46 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1KAukrV078956; Sat, 20 Feb 2016 10:56:46 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201602201056.u1KAukrV078956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Sat, 20 Feb 2016 10:56:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r295835 - stable/10/sys/boot/i386/gptboot X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2016 10:56:47 -0000 Author: smh Date: Sat Feb 20 10:56:46 2016 New Revision: 295835 URL: https://svnweb.freebsd.org/changeset/base/295835 Log: MFC r272785: Null terminate boot config buffer PR: 207070 Approved by: re (gjb) Sponsored by: Multiplay Modified: stable/10/sys/boot/i386/gptboot/gptboot.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/i386/gptboot/gptboot.c ============================================================================== --- stable/10/sys/boot/i386/gptboot/gptboot.c Sat Feb 20 07:45:21 2016 (r295834) +++ stable/10/sys/boot/i386/gptboot/gptboot.c Sat Feb 20 10:56:46 2016 (r295835) @@ -132,6 +132,7 @@ int main(void) { char cmd[512], cmdtmp[512]; + ssize_t sz; int autoboot, dskupdated; ufs_ino_t ino; @@ -160,9 +161,10 @@ main(void) for (;;) { *kname = '\0'; if ((ino = lookup(PATH_CONFIG)) || - (ino = lookup(PATH_DOTCONFIG))) - fsread(ino, cmd, sizeof(cmd)); - + (ino = lookup(PATH_DOTCONFIG))) { + sz = fsread(ino, cmd, sizeof(cmd) - 1); + cmd[(sz < 0) ? 0 : sz] = '\0'; + } if (*cmd != '\0') { memcpy(cmdtmp, cmd, sizeof(cmdtmp)); if (parse(cmdtmp, &dskupdated))