[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#4070: snmpd: hrStorageSize fix



Package: snmp
Version: 2.1.2l4-1

The following patch fixes the problem of integer wrap around that
occurs for >=2Gb disks (i.e. sbuf.f_blocks * sbuf.f_bsize > 2^31).
This is accomplished by computing the intermediate values in floating
point.

Patrick.
----------------------------------------------------------------------
--- snmp-2.1.2l4/agent/snmp_vars.c      Sun Aug 20 23:02:21 1995
+++ snmp-2.1.2l4.patched/agent/snmp_vars.c      Wed Aug  7 13:17:24 1996
@@ -3514,11 +3525,11 @@
            break;
          case HRSTORAGESIZE:
            long_return = idx < 2 ? hr_getstor (idx, HRSTORAGESIZE, 1024) :
-               (sbuf.f_blocks * sbuf.f_bsize) / 1024;
+             (long)(((float)sbuf.f_blocks * (float)sbuf.f_bsize) / 1024.0 + 0.5
);
            break;
          case HRSTORAGEUSED:
            long_return = idx < 2 ? hr_getstor (idx, HRSTORAGEUSED, 1024) :
-                     ((sbuf.f_blocks-sbuf.f_bfree) * sbuf.f_bsize) / 1024;
+             (long)(((float)(sbuf.f_blocks-sbuf.f_bfree) * sbuf.f_bsize) / 1024
.0 + 0.5);
            break;
          case HRSTORAGEALLOCFAILURES:
            long_return = 0;                    /* XXX: dummy */



Reply to: