aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/pci_util.c
diff options
context:
space:
mode:
authorhwspeedy <ns@bigbear.dk>2024-05-21 23:51:13 +0200
committerhwspeedy <ns@bigbear.dk>2024-05-21 23:51:13 +0200
commit77afc16b041bc6fbead02573d428575a55aad453 (patch)
tree7605a86607ddc36795866372c20bf9f956fc5177 /hardinfo2/pci_util.c
parentf55220d661ce66cba5d1ac35cf2310f08b900c9d (diff)
FIX Security - sscanf return value check wrong
Diffstat (limited to 'hardinfo2/pci_util.c')
-rw-r--r--hardinfo2/pci_util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/hardinfo2/pci_util.c b/hardinfo2/pci_util.c
index a97d5dc6..d721b8d6 100644
--- a/hardinfo2/pci_util.c
+++ b/hardinfo2/pci_util.c
@@ -255,7 +255,7 @@ gboolean _sysfs_bus_pci_read_hex(uint32_t dom, uint32_t bus, uint32_t dev, uint3
if (tmp && val) {
int ec = sscanf(tmp, "%x", &tval);
free(tmp);
- if (ec) {
+ if (ec==1) {
*val = tval;
return TRUE;
}
@@ -285,13 +285,13 @@ static gboolean pci_get_device_sysfs(uint32_t dom, uint32_t bus, uint32_t dev, u
tmp = _sysfs_bus_pci(dom, bus, dev, func, "max_link_speed");
if (tmp) {
ec = sscanf(tmp, "%f GT/s", &tf);
- if (ec) s->pcie_speed_max = tf;
+ if (ec==1) s->pcie_speed_max = tf;
free(tmp);
}
tmp = _sysfs_bus_pci(dom, bus, dev, func, "current_link_speed");
if (tmp) {
ec = sscanf(tmp, "%f GT/s", &tf);
- if (ec) s->pcie_speed_curr = tf;
+ if (ec==1) s->pcie_speed_curr = tf;
free(tmp);
}
tmp = _sysfs_bus_pci(dom, bus, dev, func, "max_link_width");