1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 03:09:51 +03:00

main/libpciaccess: enable -dbg, backport vgaarb fix

ref: https://gitlab.alpinelinux.org/alpine/aports/-/issues/17251
This commit is contained in:
Natanael Copa 2025-06-12 14:20:35 +00:00
parent 89646ea198
commit 8780c9e0d8
2 changed files with 75 additions and 3 deletions

View file

@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org> # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libpciaccess pkgname=libpciaccess
pkgver=0.18.1 pkgver=0.18.1
pkgrel=0 pkgrel=1
pkgdesc="X11 PCI access library" pkgdesc="X11 PCI access library"
url="https://xorg.freedesktop.org/" url="https://xorg.freedesktop.org/"
arch="all" arch="all"
@ -9,8 +9,9 @@ license="X11"
options="!check" # No test suite. options="!check" # No test suite.
depends="hwdata-pci" depends="hwdata-pci"
makedepends="meson" makedepends="meson"
subpackages="$pkgname-dev $pkgname-doc" subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc"
source="https://www.x.org/releases/individual/lib/libpciaccess-$pkgver.tar.xz" source="https://www.x.org/releases/individual/lib/libpciaccess-$pkgver.tar.xz
vgaarb-Check-snprintf-return-value.patch"
build() { build() {
abuild-meson \ abuild-meson \
@ -26,4 +27,5 @@ package() {
sha512sums=" sha512sums="
ef27999446e735df2331e94219ee3dafe9198a2472bb452f63ef9c9c446d5431f9e231e224cfabdeba1402974a5a0064546f9abced4d1770f994f5fc0c2b3310 libpciaccess-0.18.1.tar.xz ef27999446e735df2331e94219ee3dafe9198a2472bb452f63ef9c9c446d5431f9e231e224cfabdeba1402974a5a0064546f9abced4d1770f994f5fc0c2b3310 libpciaccess-0.18.1.tar.xz
c14e5b31a7cd40ba7b5bb72888d58532394f5d890f0cef91c6a7f4f6eaf1de7abbb7da887bcaf86ac4b9fcc88154cc23d274368335ca3cf68b516375a6c33ce4 vgaarb-Check-snprintf-return-value.patch
" "

View file

@ -0,0 +1,70 @@
From f73f4ca720ccb2e9939545177b54f2be099e3b54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= <jexposit@redhat.com>
Date: Tue, 19 Mar 2024 13:45:19 +0100
Subject: [PATCH] vgaarb: Check snprintf return value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
snprintf() might return a negative value if an error occurs.
Check its return value before using it in vgaarb_write().
Signed-off-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/merge_requests/35>
---
src/common_vgaarb.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index 515275f..a1edfab 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -238,6 +238,8 @@ pci_device_vgaarb_set_target(struct pci_device *dev)
len = snprintf(buf, BUFSIZE, "target PCI:%04x:%02x:%02x.%x",
dev->domain, dev->bus, dev->dev, dev->func);
+ if (len < 0 || len >= BUFSIZE)
+ return -1;
ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);
if (ret)
@@ -268,6 +270,9 @@ pci_device_vgaarb_decodes(int new_vgaarb_rsrc)
return 0;
len = snprintf(buf, BUFSIZE, "decodes %s", rsrc_to_str(new_vgaarb_rsrc));
+ if (len < 0 || len >= BUFSIZE)
+ return -1;
+
ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);
if (ret == 0)
dev->vgaarb_rsrc = new_vgaarb_rsrc;
@@ -297,6 +302,8 @@ pci_device_vgaarb_lock(void)
return 0;
len = snprintf(buf, BUFSIZE, "lock %s", rsrc_to_str(dev->vgaarb_rsrc));
+ if (len < 0 || len >= BUFSIZE)
+ return -1;
return vgaarb_write(pci_sys->vgaarb_fd, buf, len);
}
@@ -315,6 +322,8 @@ pci_device_vgaarb_trylock(void)
return 0;
len = snprintf(buf, BUFSIZE, "trylock %s", rsrc_to_str(dev->vgaarb_rsrc));
+ if (len < 0 || len >= BUFSIZE)
+ return -1;
return vgaarb_write(pci_sys->vgaarb_fd, buf, len);
}
@@ -333,6 +342,8 @@ pci_device_vgaarb_unlock(void)
return 0;
len = snprintf(buf, BUFSIZE, "unlock %s", rsrc_to_str(dev->vgaarb_rsrc));
+ if (len < 0 || len >= BUFSIZE)
+ return -1;
return vgaarb_write(pci_sys->vgaarb_fd, buf, len);
}
--
GitLab