Sanity check the return from the kernel.

We should be getting back as many bytes as we asked for, and we
don't handle shortages at all, so just reject anything that's
not right.

Differential Revision: https://reviews.freebsd.org/D15629
This commit is contained in:
Warner Losh 2018-05-31 02:57:51 +00:00
parent 3dfe152d8d
commit 92376fa76c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334413

View File

@ -220,6 +220,11 @@ devinfo_init_devices(int generation)
warn("sysctl hw.bus.devices.%d", dev_idx);
return(errno);
}
if (rlen != sizeof(udev)) {
warnx("sysctl returned wrong data %zd bytes instead of %zd",
rlen, sizeof(udev));
return (EINVAL);
}
if ((dd = malloc(sizeof(*dd))) == NULL)
return(ENOMEM);
dd->dd_dev.dd_handle = udev.dv_handle;