File U_Ignore-32-bit-domains.patch of Package libpciaccess.3612

From 099489b7917da44de57f3214425ea9b4a8f36482 Mon Sep 17 00:00:00 2001
From: Keith Busch <keith.busch@intel.com>
Date: Wed, 10 Aug 2016 17:05:23 -0600
Subject: [PATCH] Ignore 32-bit domains

A pci "domain" need not be limited to the 16-bits. The Linux kernel
currently supports 32-bit domains which cause startx to segfault. Updating
libpciaccess to support 32-bit domains breaks the library's ABI, and
domains requiring 32-bits are not necessary for startx anyway, so this
patch ignores them.

Reported-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
---
 src/linux_sysfs.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Index: libpciaccess-0.13.2/src/linux_sysfs.c
===================================================================
--- libpciaccess-0.13.2.orig/src/linux_sysfs.c
+++ libpciaccess-0.13.2/src/linux_sysfs.c
@@ -44,6 +44,7 @@
 #include <sys/mman.h>
 #include <dirent.h>
 #include <errno.h>
+#include <limits.h>
 
 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
 #include <sys/io.h>
@@ -115,18 +116,28 @@ pci_system_linux_sysfs_create( void )
 
 
 /**
- * Filter out the names "." and ".." from the scanned sysfs entries.
+ * Filter out the names "." and ".." from the scanned sysfs entries, and
+ * domains requiring 32-bits.
  *
  * \param d  Directory entry being processed by \c scandir.
  *
  * \return
- * Zero if the entry name matches either "." or "..", non-zero otherwise.
+ * Zero if the entry name matches either "." or "..", or the domain requires
+ * 32 bits, non-zero otherwise.
  *
  * \sa scandir, populate_entries
  */
 static int
 scan_sys_pci_filter( const struct dirent * d )
 {
+    if (d->d_name[0] != '.') {
+        unsigned dom = 0;
+
+        sscanf(d->d_name, "%x:", &dom);
+        if (dom > USHRT_MAX)
+            return 0;
+    }
+
     return !((strcmp( d->d_name, "." ) == 0)
 	     || (strcmp( d->d_name, ".." ) == 0));
 }
openSUSE Build Service is sponsored by