[PATCH] fix realpath vs. firefox
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Sat, 11 Apr 2020 21:08:52 +0000 (00:08 +0300)
committerTimo Aaltonen <tjaalton@debian.org>
Tue, 14 Apr 2020 13:32:57 +0000 (14:32 +0100)
Gbp-Pq: Name fix-realpath-vs-firefox.diff

xf86drm.c

index d240f95b6d08986b20ddb679e150a8d0d3325471..76e415c72de459ede6805f2706937eb972917aba 100644 (file)
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3011,9 +3011,11 @@ static int drmParseSubsystemType(int maj, int min)
     snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
     if (!realpath(path, real_path))
         return -errno;
-    snprintf(path, sizeof(path), "%s", real_path);
-
-    subsystem_type = get_subsystem_type(path);
+    subsystem_type = get_subsystem_type(real_path);
+    if (subsystem_type >= 0)
+        memcpy(path, real_path, sizeof(path));
+    else
+        subsystem_type = get_subsystem_type(path);
     if (subsystem_type == DRM_BUS_VIRTIO) {
         strncat(path, "/..", PATH_MAX);
         subsystem_type = get_subsystem_type(path);