Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2018 02:57:51 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334413 - head/lib/libdevinfo
Message-ID:  <201805310257.w4V2vpl1073279@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805310257.w4V2vpl1073279>