svn commit: r364949 - head/sys/kern
Warner Losh
imp at FreeBSD.org
Sat Aug 29 09:59:53 UTC 2020
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');
More information about the svn-src-all
mailing list