Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Feb 2016 10:56:46 +0000 (UTC)
From:      Steven Hartland <smh@FreeBSD.org>
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
Message-ID:  <201602201056.u1KAukrV078956@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602201056.u1KAukrV078956>