Author: imp
Date: Thu May 31 02:57:51 2018
New Revision: 334413
URL: https://svnweb.freebsd.org/changeset/base/334413

Log:
  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

Modified:
  head/lib/libdevinfo/devinfo.c

Modified: head/lib/libdevinfo/devinfo.c
==============================================================================
--- head/lib/libdevinfo/devinfo.c       Thu May 31 02:54:11 2018        
(r334412)
+++ head/lib/libdevinfo/devinfo.c       Thu May 31 02:57:51 2018        
(r334413)
@@ -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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to