Skip to content

Commit

Permalink
sd-device: fix segfault when error occurs in device_new_from_{nulstr,…
Browse files Browse the repository at this point in the history
…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.

Fixes #11258.
  • Loading branch information
yuwata committed Dec 30, 2018
1 parent 04ca4d1 commit 18fee12
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libsystemd/sd-device/sd-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 18fee12

Please sign in to comment.