dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Zbigniew Jędrzejewski-Szmek 2b6823
From 28c6938992e05238fa077ff820015bb37e1ecae6 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 2b6823
From: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Zbigniew Jędrzejewski-Szmek 2b6823
Date: Fri, 19 Feb 2016 15:21:18 +0100
Zbigniew Jędrzejewski-Szmek 2b6823
Subject: [PATCH] udev/path_id: correct segmentation fault due to missing NULL
Zbigniew Jędrzejewski-Szmek 2b6823
 check
Zbigniew Jędrzejewski-Szmek 2b6823
Zbigniew Jędrzejewski-Szmek 2b6823
Running "udevadm test-builtin path_id /sys/devices/platform/" results
Zbigniew Jędrzejewski-Szmek 2b6823
in a segmentation fault.
Zbigniew Jędrzejewski-Szmek 2b6823
Zbigniew Jędrzejewski-Szmek 2b6823
The problem is that udev_device_get_subsystem(dev) might return NULL
Zbigniew Jędrzejewski-Szmek 2b6823
in a streq() call.  Solve this problem by using streq_ptr() instead.
Zbigniew Jędrzejewski-Szmek 2b6823
Zbigniew Jędrzejewski-Szmek 2b6823
(cherry picked from commit 5181ab917d6407cb57043e98955f0de1614366ea)
Zbigniew Jędrzejewski-Szmek 2b6823
---
Zbigniew Jędrzejewski-Szmek 2b6823
 src/udev/udev-builtin-path_id.c | 2 +-
Zbigniew Jędrzejewski-Szmek 2b6823
 1 file changed, 1 insertion(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 2b6823
Zbigniew Jędrzejewski-Szmek 2b6823
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
Zbigniew Jędrzejewski-Szmek 2b6823
index b6ed45d8ba..6e9adc6e96 100644
Zbigniew Jędrzejewski-Szmek 2b6823
--- a/src/udev/udev-builtin-path_id.c
Zbigniew Jędrzejewski-Szmek 2b6823
+++ b/src/udev/udev-builtin-path_id.c
Zbigniew Jędrzejewski-Szmek 2b6823
@@ -712,7 +712,7 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool
Zbigniew Jędrzejewski-Szmek 2b6823
          * devices do not expose their buses and do not provide a unique
Zbigniew Jędrzejewski-Szmek 2b6823
          * and predictable name that way.
Zbigniew Jędrzejewski-Szmek 2b6823
          */
Zbigniew Jędrzejewski-Szmek 2b6823
-        if (streq(udev_device_get_subsystem(dev), "block") && !supported_transport)
Zbigniew Jędrzejewski-Szmek 2b6823
+        if (streq_ptr(udev_device_get_subsystem(dev), "block") && !supported_transport)
Zbigniew Jędrzejewski-Szmek 2b6823
                 path = mfree(path);
Zbigniew Jędrzejewski-Szmek 2b6823
 
Zbigniew Jędrzejewski-Szmek 2b6823
         if (path != NULL) {