device-mapper-multipath/0104-libmultipath-snprint_devices-avoid-NULL-dereference.patch
Benjamin Marzinski 9fdf79cddf device-mapper-multipath-0.8.5-4
Update Source to upstream version 0.8.5 plus post tag commits
  * Patches 0001-0121 are from
    https://github.com/openSUSE/multipath-tools/tree/queue and are
    already queued for upstream
  * Patches 0122&0123 have been posted for upstream inclusion
Rename files
  * Previous patches 0103-0111 are now patches 0124-0132
2021-02-11 13:53:51 -06:00

39 lines
1.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Mon, 25 Jan 2021 16:12:10 +0100
Subject: [PATCH] libmultipath: snprint_devices(): avoid NULL dereference
All libudev functions may return NULL. Watch out for it.
Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate"
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/print.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 19de2c7c..8151e11e 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -2055,8 +2055,16 @@ int snprint_devices(struct config *conf, char *buff, size_t len,
struct udev_device *u_dev;
path = udev_list_entry_get_name(item);
+ if (!path)
+ continue;
u_dev = udev_device_new_from_syspath(udev, path);
+ if (!u_dev)
+ continue;
devname = udev_device_get_sysname(u_dev);
+ if (!devname) {
+ udev_device_unref(u_dev);
+ continue;
+ }
fwd += snprintf(buff + fwd, len - fwd, " %s", devname);
if (fwd >= len)
--
2.17.2