Fix a logic bug in error handling code. It is an error if p == NULL.

The linelen tests are only meaningful when p != NULL.

Reported by:	Coverity
Coverity CID:	1368655
MFC after:	1 month
This commit is contained in:
Don Lewis 2019-12-09 07:18:40 +00:00
parent 7887f00d2b
commit 1bf6738f80
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355553

View File

@ -542,7 +542,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
goto err;
}
p = fgetln(sfd, &linelen);
if (p == NULL &&
if (p == NULL ||
(linelen < 2 || linelen > sizeof(linebuf))) {
warn("mdconfig (attach) unexpected output");
ret = NULL;