From 8355e44d8ce0f973fee278c9e2b168b845ae4d69 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 31 May 2006 00:59:14 +0000 Subject: [PATCH] cast to prevent possible integer overflow in filesystem_usage --- src/os/aix/aix_sigar.c | 2 +- src/os/darwin/darwin_sigar.c | 2 +- src/os/hpux/hpux_sigar.c | 2 +- src/os/linux/linux_sigar.c | 2 +- src/os/osf1/osf1_sigar.c | 2 +- src/os/solaris/solaris_sigar.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index 06f54610..7efe5456 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -1574,7 +1574,7 @@ int sigar_file_system_list_get(sigar_t *sigar, /* XXX this is exactly the same as linux and hpux, solaris is darn close */ #define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \ - ((buf.f * (buf.f_bsize / 512)) >> 1) + (((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1) #define LSPV_CMD "/usr/sbin/lspv" diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index f9038207..7930f3c6 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -288,7 +288,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) } #define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \ - ((buf.f * (buf.f_bsize / 512)) >> 1) + (((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1) #define VM_DIR "/private/var/vm" #define SWAPFILE "swapfile" diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index c807b4c1..55b061c1 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -523,7 +523,7 @@ int sigar_file_system_list_get(sigar_t *sigar, #include #define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \ - ((buf.f * (buf.f_bsize / 512)) >> 1) + (((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1) #define FSDEV_ID(sb) (sb.st_ino + sb.st_dev) diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 4c5cc7e7..520b008d 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -1343,7 +1343,7 @@ static int get_iostat_procp(sigar_t *sigar, #include #define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \ - ((buf.f * (buf.f_bsize / 512)) >> 1) + (((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1) int sigar_file_system_usage_get(sigar_t *sigar, const char *dirname, diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index 4c54b815..267e29a5 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -446,7 +446,7 @@ int sigar_file_system_list_get(sigar_t *sigar, } #define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \ - ((buf.f * (buf.f_bsize / 512)) >> 1) + (((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1) int sigar_file_system_usage_get(sigar_t *sigar, const char *dirname, diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 1e3cb8ac..952878ed 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -1241,7 +1241,7 @@ int sigar_file_system_list_get(sigar_t *sigar, #include #define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \ - ((buf.f * (buf.f_frsize / 512)) >> 1) + (((sigar_uint64_t)buf.f * (buf.f_frsize / 512)) >> 1) typedef struct { char device[PATH_MAX];