svn commit: r364441 - head/stand/i386/zfsboot

Gleb Smirnoff glebius at FreeBSD.org
Thu Aug 20 20:31:48 UTC 2020


Author: glebius
Date: Thu Aug 20 20:31:47 2020
New Revision: 364441
URL: https://svnweb.freebsd.org/changeset/base/364441

Log:
  When we have a command returned by zfs_nextboot() that is longer
  than command in the loader.conf, the latter needs to be nul terminated,
  otherwise garbage trailer left from zfs_nextboot() will be passed to
  parse_cmd() together with loader.conf command.
  
  While here, reset cmd to empty string if read() returns error.
  
  Reviewed by:	tsoome

Modified:
  head/stand/i386/zfsboot/zfsboot.c

Modified: head/stand/i386/zfsboot/zfsboot.c
==============================================================================
--- head/stand/i386/zfsboot/zfsboot.c	Thu Aug 20 20:11:58 2020	(r364440)
+++ head/stand/i386/zfsboot/zfsboot.c	Thu Aug 20 20:31:47 2020	(r364441)
@@ -248,7 +248,12 @@ main(void)
 		fd = open(PATH_DOTCONFIG, O_RDONLY);
 
 	if (fd != -1) {
-		read(fd, cmd, sizeof (cmd));
+		ssize_t cmdlen;
+
+		if ((cmdlen = read(fd, cmd, sizeof(cmd))) > 0)
+			cmd[cmdlen] = '\0';
+		else
+			*cmd = '\0';
 		close(fd);
 	}
 


More information about the svn-src-all mailing list