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:
truckman 2019-12-09 07:18:40 +00:00
parent 349ee9cd62
commit f9e1d0b7ba

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;