diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2022-11-09 18:33:43 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2022-11-09 18:33:43 +0000 |
commit | 3f11fa33ebe3679340979d5add8969ad4989565e (patch) | |
tree | 10d78c0b3b1c655697a78bf16cf333f1958b2039 | |
parent | 507ec1eb0b718f95fdbc1d3a9829bf6648d1924c (diff) |
Fix running totally unprivileged with startx(1).
Issue reported by Walter Alejandro Iglesias.
-rw-r--r-- | lib/libpciaccess/src/openbsd_pci.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libpciaccess/src/openbsd_pci.c b/lib/libpciaccess/src/openbsd_pci.c index 2ce0401dd..2bf45c32f 100644 --- a/lib/libpciaccess/src/openbsd_pci.c +++ b/lib/libpciaccess/src/openbsd_pci.c @@ -745,7 +745,7 @@ pci_system_openbsd_init_dev_mem(int fd) int pci_device_vgaarb_init(void) { - struct pci_device *dev = pci_sys->vga_target; + struct pci_device *dev; struct pci_device_iterator *iter; struct pci_id_match vga_match = { PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, @@ -754,12 +754,16 @@ pci_device_vgaarb_init(void) }; struct pci_vga pv; int err; - #ifdef CPU_ALLOWAPERTURE int mib[2]; int allowaperture; size_t len; +#endif + + if (pci_sys == NULL) + return ENXIO; +#ifdef CPU_ALLOWAPERTURE mib[0] = CTL_MACHDEP; mib[1] = CPU_ALLOWAPERTURE; len = sizeof(allowaperture); @@ -770,7 +774,7 @@ pci_device_vgaarb_init(void) return 0; } #endif - + dev = pci_sys->vga_target; pv.pv_sel.pc_bus = 0; pv.pv_sel.pc_dev = 0; pv.pv_sel.pc_func = 0; |