File procps-3.2.8-integer-overflow.patch of Package procps

---
 free.c         |   26 +++++++++++++++++++++++---
 proc/sysinfo.c |   12 ++++++++++--
 2 files changed, 33 insertions(+), 5 deletions(-)

Index: procps-3.2.8/proc/sysinfo.c
===================================================================
--- procps-3.2.8.orig/proc/sysinfo.c	2008-03-24 05:33:43.000000000 +0100
+++ procps-3.2.8/proc/sysinfo.c	2009-08-17 17:57:29.000000000 +0200
@@ -617,9 +617,17 @@ nextline:
   if(kb_inactive==~0UL){
     kb_inactive = kb_inact_dirty + kb_inact_clean + kb_inact_laundry;
   }
-  kb_swap_used = kb_swap_total - kb_swap_free;
-  kb_main_used = kb_main_total - kb_main_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_total > kb_main_free) {
+    kb_main_used = kb_main_total - kb_main_free;
+  } else {
+    kb_main_used = 0;
+  }
   kb_main_cached += kb_swap_reclaimable + kb_swap_cached + kb_nfs_unstable;
 }
 
 /*****************************************************************/
Index: procps-3.2.8/free.c
===================================================================
--- procps-3.2.8.orig/free.c	2004-01-30 03:30:29.000000000 +0100
+++ procps-3.2.8/free.c	2009-08-17 18:04:23.000000000 +0200
@@ -76,24 +76,44 @@ int main(int argc, char *argv[]){
         // not export the low and high stats.  Note we still want to
         // print the high info, even if it is zero.
         if (show_high) {
+            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 %10Lu %10Lu %10Lu\n", "Low:",
                 S(kb_low_total),
-                S(kb_low_total - kb_low_free),
+                S(kb_low_used),
                 S(kb_low_free)
             );
             printf(
                 "%-7s %10Lu %10Lu %10Lu\n", "High:",
                 S(kb_high_total),
-                S(kb_high_total - kb_high_free),
+                S(kb_high_used),
                 S(kb_high_free)
             );
         }
         if(!old_fmt){
             unsigned KLONG buffers_plus_cached = kb_main_buffers + kb_main_cached;
+            unsigned long kb_used_minus_bufcache;
+
+            if (kb_main_used > buffers_plus_cached)
+                kb_used_minus_bufcache = kb_main_used - buffers_plus_cached;
+            else
+                kb_used_minus_bufcache = 0;
+
             printf(
                 "-/+ buffers/cache: %10Lu %10Lu\n", 
-                S(kb_main_used - buffers_plus_cached),
+                S(kb_used_minus_bufcache),
                 S(kb_main_free + buffers_plus_cached)
             );
         }
openSUSE Build Service is sponsored by