Date: Thu, 20 Aug 2020 20:31:47 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364441 - head/stand/i386/zfsboot Message-ID: <202008202031.07KKVlHv032002@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008202031.07KKVlHv032002>