Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Aug 2020 09:59:52 +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: r364949 - head/sys/kern
Message-ID:  <202008290959.07T9xq5K011901@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sat Aug 29 09:59:52 2020
New Revision: 364949
URL: https://svnweb.freebsd.org/changeset/base/364949

Log:
  Avoid NULL pointer dereferences
  
  Add back NULL pointer checks accidentally dropped in r364946. We need
  to append a NUL character when that happens.

Modified:
  head/sys/kern/subr_bus.c

Modified: head/sys/kern/subr_bus.c
==============================================================================
--- head/sys/kern/subr_bus.c	Sat Aug 29 06:55:10 2020	(r364948)
+++ head/sys/kern/subr_bus.c	Sat Aug 29 09:59:52 2020	(r364949)
@@ -5499,11 +5499,20 @@ sysctl_devices(SYSCTL_HANDLER_ARGS)
 	udev->dv_flags = dev->flags;
 	udev->dv_state = dev->state;
 	sbuf_new(&sb, udev->dv_fields, sizeof(udev->dv_fields), SBUF_FIXEDLEN);
-	sbuf_cat(&sb, dev->nameunit);
+	if (dev->nameunit != NULL)
+		sbuf_cat(&sb, dev->nameunit);
+	else
+		sbuf_putc(&sb, '\0');
 	sbuf_putc(&sb, '\0');
-	sbuf_cat(&sb, dev->desc);
+	if (dev->desc != NULL)
+		sbuf_cat(&sb, dev->desc);
+	else
+		sbuf_putc(&sb, '\0');
 	sbuf_putc(&sb, '\0');
-	sbuf_cat(&sb, dev->driver != NULL ? dev->driver->name : '\0');
+	if (dev->driver != NULL)
+		sbuf_cat(&sb, dev->driver->name);
+	else
+		sbuf_putc(&sb, '\0');
 	sbuf_putc(&sb, '\0');
 	bus_child_pnpinfo_sb(dev, &sb);
 	sbuf_putc(&sb, '\0');



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