improve hardware probes+ legacy cleanup

This commit is contained in:
deepend committed 2026-12-04 18:29:17 -06:00
1 parent 27f5730f50
commit 5c8036ad80
2 files changed
+36 -18

No files matched your search

+16 -11
View File
@@ -116,7 +116,7 @@ read_hex_file (const char *path, guint *value)
errno = 0;
parsed = g_ascii_strtoull (contents, &end, 16);
if (errno != 0 || end == contents)
if (errno != 0 || end == contents || *end != '\0' || parsed > G_MAXUINT || contents[0] == '-')
{
g_free (contents);
return FALSE;
@@ -535,19 +535,22 @@ scan_pci_devices (void)
gpus = g_ptr_array_new_with_free_func (g_free);
chipsets = g_ptr_array_new_with_free_func (g_free);
dir = g_dir_open ("/sys/bus/pci/devices", 0, NULL);
#ifdef HAVE_LIBPCI
/* We only need name lookup: autodetection can exit the client if sysfs
* is hidden in a sandbox and libpci tries privileged access methods.
* Explicit sysfs initialization installs callbacks without probing. */
if (pci_lookup_method ("linux-sysfs") >= 0)
/* Only initialize the explicit sysfs method when PCI is visible. Never
* use autodetection or ask libpci to probe/configure a device. */
if (dir)
{
pacc = pci_alloc ();
pacc->method = pci_lookup_method ("linux-sysfs");
pci_init (pacc);
int method = pci_lookup_method ("linux-sysfs");
if (method >= 0)
{
pacc = pci_alloc ();
pacc->method = method;
pci_init (pacc);
}
}
#endif
dir = g_dir_open ("/sys/bus/pci/devices", 0, NULL);
if (dir)
{
while ((entry = g_dir_read_name (dir)) != NULL)
@@ -614,8 +617,9 @@ scan_pci_devices (void)
g_free (gpu_name);
}
}
else if (class_subclass == 0x0600)
else if (class_subclass == 0x0600 || class_subclass == 0x0601)
{
/* Include host bridges and ISA/LPC bridges. */
ptr_array_add_unique (chipsets, name);
}
@@ -821,7 +825,8 @@ sysinfo_backend_get_uptime (void)
}
uptime = g_ascii_strtod (contents, &end);
if (end == contents || uptime <= 0.0)
/* Comparisons also reject NaN, infinity and out-of-range conversions. */
if (end == contents || !(uptime >= 0.0 && uptime < (double) G_MAXINT64))
{
g_free (contents);
return NULL;