summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2020-07-01 16:41:44 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2020-07-01 16:41:44 +0000
commit6aceac310b57d42080ec81327f6bc41a5c8deae7 (patch)
tree365eabec9f811db3e225dac96416b314665da3ef /usr.sbin
parent02306e50ded439b2560da2160239bc9f7e2785fa (diff)
Allow hrStorageSize and hrStorageUsed to cope with sizes larger then
INT32_MAX by increasing the hrStorageAllocationUnits value until they fit. Original patch from Johan Huldtgren (johan+openbsd-tech <at> huldtgren <dot> com) OK sthen@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/snmpd/mib.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c
index 8df725ba2ae..991725cc261 100644
--- a/usr.sbin/snmpd/mib.c
+++ b/usr.sbin/snmpd/mib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mib.c,v 1.99 2020/05/15 00:56:03 cheloha Exp $ */
+/* $OpenBSD: mib.c,v 1.100 2020/07/01 16:41:43 martijn Exp $ */
/*
* Copyright (c) 2012 Joel Knight <joel@openbsd.org>
@@ -563,7 +563,7 @@ mib_hrstorage(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
u_int32_t idx;
struct statfs *mntbuf, *mnt;
int mntsize, maxsize;
- u_int32_t units, size, used, fail = 0;
+ u_int64_t units, size, used, fail = 0;
const char *descr = NULL;
int mib[] = { CTL_HW, 0 };
u_int64_t physmem, realmem;
@@ -647,6 +647,12 @@ mib_hrstorage(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
break;
}
+ while (size > INT32_MAX) {
+ units *= 2;
+ size /= 2;
+ used /= 2;
+ }
+
/* Tables need to prepend the OID on their own */
o->bo_id[OIDIDX_hrStorageEntry] = idx;
ber = ober_add_oid(ber, o);