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
This commit is contained in:
parent
e627909d04
commit
c7dd069c70
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user