fix divison-by-zero in cpu statistics Resolves: #501210

This commit is contained in:
Jan Šafránek 2009-05-18 10:35:17 +00:00
parent 38456140b9
commit 21066a2818
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,21 @@
501210: net-snmp SIGFPE 0x00002aaaab37744a in var_hrproc (vp=0x7fffffffbf50)
Author: Jan Safranek <jsafrane@redhat.com>
Upstream as SVN rev. 17616.
Index: net-snmp/agent/mibgroup/host/hr_proc.c
===================================================================
--- net-snmp/agent/mibgroup/host/hr_proc.c (revision 17615)
+++ net-snmp/agent/mibgroup/host/hr_proc.c (working copy)
@@ -182,7 +182,10 @@
return NULL;
long_return = (cpu->idle_ticks - cpu->history[0].idle_hist)*100;
- long_return /= (cpu->total_ticks - cpu->history[0].total_hist);
+ if (cpu->total_ticks > cpu->history[0].total_hist) /* avoid div. by 0 */
+ long_return /= (cpu->total_ticks - cpu->history[0].total_hist);
+ else
+ long_return = 0;
long_return = 100 - long_return;
if (long_return < 0)
long_return = 0;

View File

@ -8,7 +8,7 @@
Summary: A collection of SNMP protocol tools and libraries
Name: net-snmp
Version: %{major_ver}
Release: 10%{?dist}
Release: 11%{?dist}
Epoch: 1
License: BSD and MIT
@ -35,6 +35,7 @@ Patch10: net-snmp-5.4.1-shared-ip.patch
Patch11: net-snmp-5.4.1-sensors3.patch
Patch12: net-snmp-5.4.1-xen-crash.patch
Patch13: net-snmp-5.4.1-libwrap.patch
Patch14: net-snmp-5.4.2.1-proc-div0.patch
Requires(pre): chkconfig
Requires(post): chkconfig
@ -173,6 +174,7 @@ Net-SNMP toolkit library.
%patch11 -p1 -b .sensors
%patch12 -p1 -b .xen-crash
%patch13 -p1 -b .libwrap
%patch14 -p1 -b .proc-div0
# Do this patch with a perl hack...
perl -pi -e "s|'\\\$install_libdir'|'%{_libdir}'|" ltmain.sh
@ -421,6 +423,9 @@ rm -rf ${RPM_BUILD_ROOT}
%{_datadir}/snmp/mibs
%changelog
* Mon May 18 2009 Jan Safranek <jsafranek@redhat.com> 5.4.2.1-11
- fix divison-by-zero in cpu statistics (#501210)
* Fri Mar 06 2009 Jesse Keating <jkeating@redhat.com> - 5.4.2.1-10
- Rebuild for new rpm