procps/procps-3.2.8-integer-overflow.patch
Pavol Rusnak 77ebc0f6b2 Accepting request 41962 from home:mszeredi:branches:Base:System
Copy from home:mszeredi:branches:Base:System/procps via accept of submit request 41962 revision 3.
Request was accepted with message:
Reviewed ok

OBS-URL: https://build.opensuse.org/request/show/41962
OBS-URL: https://build.opensuse.org/package/show/Base:System/procps?expand=0&rev=23
2010-06-25 15:53:12 +00:00

82 lines
2.9 KiB
Diff

---
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)
);
}