Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jul 2016 22:19:25 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r302688 - stable/10/sbin/sysctl
Message-ID:  <201607122219.u6CMJPww037097@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Tue Jul 12 22:19:25 2016
New Revision: 302688
URL: https://svnweb.freebsd.org/changeset/base/302688

Log:
  MFC r302174
  
  Fix "sysctl vm.vmtotal" output on machines with > 2TB virtual memory
  
  sbin/sysctl/sysctl.c
          Fix integer overflows in printf format strings
  
  PR:		199673

Modified:
  stable/10/sbin/sysctl/sysctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/sysctl/sysctl.c
==============================================================================
--- stable/10/sbin/sysctl/sysctl.c	Tue Jul 12 22:09:05 2016	(r302687)
+++ stable/10/sbin/sysctl/sysctl.c	Tue Jul 12 22:19:25 2016	(r302688)
@@ -547,15 +547,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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607122219.u6CMJPww037097>