From 0629a081db1aed7bad858f7dea045b57562d6e31 Mon Sep 17 00:00:00 2001 From: Nick Owens Date: Mon, 8 Jan 2018 06:36:49 -0800 Subject: [PATCH] multiply page size after float64 coercion to avoid signed integer overflow (#780) --- collector/meminfo_openbsd.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/collector/meminfo_openbsd.go b/collector/meminfo_openbsd.go index 377b458e..00edb163 100644 --- a/collector/meminfo_openbsd.go +++ b/collector/meminfo_openbsd.go @@ -47,19 +47,19 @@ func (c *meminfoCollector) getMemInfo() (map[string]float64, error) { return nil, fmt.Errorf("sysctl CTL_VM VM_UVMEXP failed: %v", err) } - ps := uvmexp.pagesize + ps := float64(uvmexp.pagesize) // see uvm(9) return map[string]float64{ - "active_bytes": float64(ps * uvmexp.active), - "cache_bytes": float64(ps * uvmexp.vnodepages), - "free_bytes": float64(ps * uvmexp.free), - "inactive_bytes": float64(ps * uvmexp.inactive), - "size_bytes": float64(ps * uvmexp.npages), - "swap_size_bytes": float64(ps * uvmexp.swpages), - "swap_used_bytes": float64(ps * uvmexp.swpgonly), - "swapped_in_pages_bytes_total": float64(ps * uvmexp.pgswapin), - "swapped_out_pages_bytes_total": float64(ps * uvmexp.pgswapout), - "wired_bytes": float64(ps * uvmexp.wired), + "active_bytes": ps * float64(uvmexp.active), + "cache_bytes": ps * float64(uvmexp.vnodepages), + "free_bytes": ps * float64(uvmexp.free), + "inactive_bytes": ps * float64(uvmexp.inactive), + "size_bytes": ps * float64(uvmexp.npages), + "swap_size_bytes": ps * float64(uvmexp.swpages), + "swap_used_bytes": ps * float64(uvmexp.swpgonly), + "swapped_in_pages_bytes_total": ps * float64(uvmexp.pgswapin), + "swapped_out_pages_bytes_total": ps * float64(uvmexp.pgswapout), + "wired_bytes": ps * float64(uvmexp.wired), }, nil }