* [dm-devel] [PATCH] libmultipath: snprint_devices(): avoid NULL dereference
@ 2021-01-25 15:23 mwilck
2021-01-25 21:46 ` Benjamin Marzinski
0 siblings, 1 reply; 2+ messages in thread
From: mwilck @ 2021-01-25 15:23 UTC (permalink / raw)
To: Christophe Varoqui, Benjamin Marzinski, lixiaokeng; +Cc: dm-devel, Martin Wilck
From: Martin Wilck <mwilck@suse.com>
All libudev functions may return NULL. Watch out for it.
Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate"
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/print.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 19de2c7..8151e11 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.29.2
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [dm-devel] [PATCH] libmultipath: snprint_devices(): avoid NULL dereference
2021-01-25 15:23 [dm-devel] [PATCH] libmultipath: snprint_devices(): avoid NULL dereference mwilck
@ 2021-01-25 21:46 ` Benjamin Marzinski
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Marzinski @ 2021-01-25 21:46 UTC (permalink / raw)
To: mwilck; +Cc: lixiaokeng, dm-devel
On Mon, Jan 25, 2021 at 04:23:04PM +0100, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
>
> All libudev functions may return NULL. Watch out for it.
>
> Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate"
> Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-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 19de2c7..8151e11 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.29.2
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-25 21:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 15:23 [dm-devel] [PATCH] libmultipath: snprint_devices(): avoid NULL dereference mwilck
2021-01-25 21:46 ` Benjamin Marzinski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.