diff options
author | asomers <asomers@FreeBSD.org> | 2016-06-24 14:58:37 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2016-06-24 14:58:37 +0000 |
commit | b5c3fb9427806b740f7df3e43a1513e1f5fa840b (patch) | |
tree | b86782d0818438402b2ea7521b0fdf981b8234c8 /sbin/sysctl | |
parent | 57ab70285addea7d91323a5ddd463d23806a05cc (diff) | |
download | FreeBSD-src-b5c3fb9427806b740f7df3e43a1513e1f5fa840b.zip FreeBSD-src-b5c3fb9427806b740f7df3e43a1513e1f5fa840b.tar.gz |
Fix "sysctl vm.vmtotal" output on machines with > 2TB virtual memory
sbin/sysctl/sysctl.c
Fix integer overflows in printf format strings
PR: 199673
Submitted by: Vitaly Magerya
Reviewed by: cem
Approved by: re (marius)
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D6941
Diffstat (limited to 'sbin/sysctl')
-rw-r--r-- | sbin/sysctl/sysctl.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 6b493c6..f2d42a8 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -623,15 +623,15 @@ S_vmtotal(size_t l2, void *p) "%hd Sleep: %hd)\n", v->t_rq, v->t_dw, v->t_pw, v->t_sl); printf( - "Virtual Memory:\t\t(Total: %dK Active: %dK)\n", - v->t_vm * pageKilo, v->t_avm * pageKilo); - printf("Real Memory:\t\t(Total: %dK Active: %dK)\n", - v->t_rm * pageKilo, v->t_arm * pageKilo); - printf("Shared Virtual Memory:\t(Total: %dK Active: %dK)\n", - v->t_vmshr * pageKilo, v->t_avmshr * pageKilo); - printf("Shared Real Memory:\t(Total: %dK Active: %dK)\n", - v->t_rmshr * pageKilo, v->t_armshr * pageKilo); - printf("Free Memory:\t%dK", v->t_free * pageKilo); + "Virtual Memory:\t\t(Total: %jdK Active: %jdK)\n", + (intmax_t)v->t_vm * pageKilo, (intmax_t)v->t_avm * pageKilo); + printf("Real Memory:\t\t(Total: %jdK Active: %jdK)\n", + (intmax_t)v->t_rm * pageKilo, (intmax_t)v->t_arm * pageKilo); + printf("Shared Virtual Memory:\t(Total: %jdK Active: %jdK)\n", + (intmax_t)v->t_vmshr * pageKilo, (intmax_t)v->t_avmshr * pageKilo); + printf("Shared Real Memory:\t(Total: %jdK Active: %jdK)\n", + (intmax_t)v->t_rmshr * pageKilo, (intmax_t)v->t_armshr * pageKilo); + printf("Free Memory:\t%jdK", (intmax_t)v->t_free * pageKilo); return (0); } |