From: Yu Watanabe Date: Sat, 22 Dec 2018 18:06:47 +0000 (+0900) Subject: sd-device: fix segfault when error occurs in device_new_from_{nulstr,strv}() X-Git-Tag: archive/raspbian/240-2+rpi1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0948e9011f1dc836b9126ef810b0e84d49961c35;p=systemd.git sd-device: fix segfault when error occurs in device_new_from_{nulstr,strv}() As devpath may not be set yet. When debug logging is enabled, log_device_*() calls sd_device_get_sysname(). So, we should not assume that devpath is always set. Gbp-Pq: Topic debian Gbp-Pq: Name sd-device-fix-segfault-when-error-occurs-in-device_new_fr.patch --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index db58615d..9b1ef444 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1002,6 +1002,9 @@ static int device_set_sysname(sd_device *device) { const char *pos; size_t len = 0; + if (!device->devpath) + return -EINVAL; + pos = strrchr(device->devpath, '/'); if (!pos) return -EINVAL;