File procps-ng-3.3.10-integer-overflow.patch of Package procps
---
free.c | 17 +++++++++++++++--
proc/sysinfo.c | 5 ++++-
2 files changed, 19 insertions(+), 3 deletions(-)
--- free.c
+++ free.c 2016-07-11 13:05:52.351515040 +0000
@@ -387,15 +387,28 @@ int main(int argc, char **argv)
* to print the high info, even if it is zero.
*/
if (flags & FREE_LOHI) {
+ unsigned long kb_low_used;
+ unsigned long kb_high_used;
+
+ if (kb_low_total > kb_low_free)
+ kb_low_used = kb_low_total - kb_low_free;
+ else
+ kb_low_used = 0;
+
+ if (kb_high_total > kb_high_free)
+ kb_high_used = kb_high_total - kb_high_free;
+ else
+ kb_high_used = 0;
+
printf("%-7s", _("Low:"));
printf(" %11s", scale_size(kb_low_total, flags, args));
- printf(" %11s", scale_size(kb_low_total - kb_low_free, flags, args));
+ printf(" %11s", scale_size(kb_low_used, flags, args));
printf(" %11s", scale_size(kb_low_free, flags, args));
printf("\n");
printf("%-7s", _("High:"));
printf(" %11s", scale_size(kb_high_total, flags, args));
- printf(" %11s", scale_size(kb_high_total - kb_high_free, flags, args));
+ printf(" %11s", scale_size(kb_high_used, flags, args));
printf(" %11s", scale_size(kb_high_free, flags, args));
printf("\n");
}
--- proc/sysinfo.c
+++ proc/sysinfo.c 2016-07-11 13:08:00.145047300 +0000
@@ -709,7 +709,10 @@ nextline:
kb_main_cached = kb_page_cache + kb_slab_reclaimable;
if ((ev=getenv("PS_FULL_CACHE")))
kb_main_cached += kb_swap_cached + kb_nfs_unstable;
- kb_swap_used = kb_swap_total - kb_swap_free;
+ if (kb_swap_total > kb_swap_free)
+ kb_swap_used = kb_swap_total - kb_swap_free;
+ else
+ kb_swap_used = 0;
/* if kb_main_available is greater than kb_main_total or our calculation of
mem_used overflows, that's symptomatic of running within a lxc container