[papi] Fix overrun in lmsensor component. (rhbz797692)

William Eden Cohen wcohen at fedoraproject.org
Fri Mar 9 21:37:07 UTC 2012


commit c98dcf56a85e4ebf806f64525821104fa4c3b812
Author: William Cohen <wcohen at redhat.com>
Date:   Fri Mar 9 16:36:44 2012 -0500

    Fix overrun in lmsensor component. (rhbz797692)

 papi-bz797692.patch |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 papi.spec           |    7 ++-
 2 files changed, 209 insertions(+), 1 deletions(-)
---
diff --git a/papi-bz797692.patch b/papi-bz797692.patch
new file mode 100644
index 0000000..c908dcd
--- /dev/null
+++ b/papi-bz797692.patch
@@ -0,0 +1,203 @@
+diff -up papi-4.2.1/src/components/lmsensors/linux-lmsensors.c.bz papi-4.2.1/src/components/lmsensors/linux-lmsensors.c
+--- papi-4.2.1/src/components/lmsensors/linux-lmsensors.c.bz	2012-02-10 14:58:08.000000000 -0500
++++ papi-4.2.1/src/components/lmsensors/linux-lmsensors.c	2012-03-09 16:23:20.139608076 -0500
+@@ -4,11 +4,11 @@
+ #include "papi_memory.h"
+ #include "linux-lmsensors.h"
+ 
++papi_vector_t _lmsensors_vector;
+ 
+-
+-/*******************************************************************************
+- ********  BEGIN FUNCTIONS  USED INTERNALLY SPECIFIC TO THIS COMPONENT *********
+- ******************************************************************************/
++/******************************************************************************
++ ********  BEGIN FUNCTIONS  USED INTERNALLY SPECIFIC TO THIS COMPONENT ********
++ *****************************************************************************/
+ /*
+  * Counts number of events available in this system
+  */
+@@ -50,72 +50,69 @@ createNativeEvents( void )
+ 	int chip_nr = 0;
+ 	const sensors_chip_name *chip_name;
+ 
+-	cmp_id_t component;
+-
+ 	/* component name and description */
+-	strcpy( component.name, "LM_SENSORS" );
+-	strcpy( component.descr,
+-			"lm-sensors provides tools for monitoring the hardware health" );
++	strcpy( _lmsensors_vector.cmp_info.name, "LM_SENSORS" );
++	// strcpy( _lmsensors_vector.cmp_info.descr,
++	//		"lm-sensors provides tools for monitoring the hardware health" );
+ 
+ 
+ 	/* Loop through all the chips found */
+ 	while ( ( chip_name =
+ 			  sensors_get_detected_chips( NULL, &chip_nr ) ) != NULL ) {
+-		int a, b;
+-		const sensors_feature *feature;
+-		const sensors_subfeature *sub;
+-		char chipnamestring[PAPI_MIN_STR_LEN];
++	   int a, b;
++	   const sensors_feature *feature;
++	   const sensors_subfeature *sub;
++	   char chipnamestring[PAPI_MIN_STR_LEN];
+ 
+-		lm_sensors_native_table[id].count = 0;
++	   //	   lm_sensors_native_table[id].count = 0;
+ 
+ 		/* get chip name from its internal representation */
+-		sensors_snprintf_chip_name( chipnamestring,
+-									PAPI_MIN_STR_LEN, chip_name );
++	   sensors_snprintf_chip_name( chipnamestring,
++					    PAPI_MIN_STR_LEN, chip_name );
+ 
+-		a = 0;
+-		/* Loop through all the features found */
+-		while ( ( feature = sensors_get_features( chip_name, &a ) ) ) {
+-			char *featurelabel;
++	   a = 0;
++
++	   /* Loop through all the features found */
++	   while ( ( feature = sensors_get_features( chip_name, &a ) ) ) {
++	      char *featurelabel;
+ 
+-			if ( !( featurelabel = sensors_get_label( chip_name, feature ) ) ) {
+-				fprintf( stderr, "ERROR: Can't get label of feature %s!\n",
++	      if ( !( featurelabel = sensors_get_label( chip_name, feature ))) {
++		 fprintf( stderr, "ERROR: Can't get label of feature %s!\n",
+ 						 feature->name );
+-				continue;
+-			}
++		 continue;
++	      }
+ 
+-			b = 0;
++	      b = 0;
+ 
+-			/* Loop through all the subfeatures found */
+-			while ( ( sub =
+-					  sensors_get_all_subfeatures( chip_name, feature,
+-												   &b ) ) ) {
+-				count = 0;
++	      /* Loop through all the subfeatures found */
++	      while ((sub=sensors_get_all_subfeatures(chip_name,feature,&b))) {
+ 
+-				/* Save native event data */
+-				sprintf( lm_sensors_native_table[id].name,
+-						 "%s.%s.%s.%s",
+-						 component.name,
+-						 chipnamestring, featurelabel, sub->name );
++	         count = 0;
+ 
+-				strncpy( lm_sensors_native_table[id].description,
+-						 lm_sensors_native_table[id].name, PAPI_MAX_STR_LEN );
++		 /* Save native event data */
++		 sprintf( lm_sensors_native_table[id].name, "%s.%s.%s.%s",
++			  _lmsensors_vector.cmp_info.name,
++			  chipnamestring, featurelabel, sub->name );
+ 
+-				/* The selector has to be !=0 . Starts with 1 */
+-				lm_sensors_native_table[id].resources.selector = id + 1;
++		 strncpy( lm_sensors_native_table[id].description,
++			  lm_sensors_native_table[id].name, PAPI_MAX_STR_LEN );
+ 
+-				/* Save the actual references to this event */
+-				lm_sensors_native_table[id].resources.name = chip_name;
+-				lm_sensors_native_table[id].resources.subfeat_nr = sub->number;
++		 /* The selector has to be !=0 . Starts with 1 */
++		 lm_sensors_native_table[id].resources.selector = id + 1;
+ 
+-				count = sub->number;
++		 /* Save the actual references to this event */
++		 lm_sensors_native_table[id].resources.name = chip_name;
++		 lm_sensors_native_table[id].resources.subfeat_nr = sub->number;
+ 
+-				/* increment the table index counter */
+-				id++;
+-			}
++		 count = sub->number;
+ 
+-			lm_sensors_native_table[id].count = count + 1;
+-			free( featurelabel );
+-		}
++		 /* increment the table index counter */
++		 id++;		 
++	      }
++
++	      //   lm_sensors_native_table[id].count = count + 1;
++	      free( featurelabel );
++	   }
+ 	}
+ 
+ 	/* Return the number of events created */
+@@ -179,6 +176,7 @@ LM_SENSORS_init_substrate(  )
+ 
+ 	/* Create dyanmic events table */
+ 	NUM_EVENTS = detectSensors(  );
++	//printf("Found %d sensors\n",NUM_EVENTS);
+ 
+ 	if ( ( lm_sensors_native_table =
+ 		   ( LM_SENSORS_native_event_entry_t * )
+@@ -193,7 +191,7 @@ LM_SENSORS_init_substrate(  )
+ 		return EXIT_FAILURE;
+ 	}
+ 
+-	return ( PAPI_OK );
++	return PAPI_OK;
+ }
+ 
+ 
+@@ -224,7 +222,8 @@ LM_SENSORS_start( hwd_context_t * ctx, h
+ {
+ 	( void ) ctx;
+ 	( void ) ctrl;
+-	return ( PAPI_OK );
++
++	return PAPI_OK;
+ }
+ 
+ 
+@@ -235,8 +234,9 @@ int
+ LM_SENSORS_stop( hwd_context_t * ctx, hwd_control_state_t * ctrl )
+ {
+     ( void ) ctx;
+-	( void ) ctrl;
+-	return ( PAPI_OK );
++    ( void ) ctrl;
++
++    return PAPI_OK;
+ }
+ 
+ 
+@@ -444,9 +444,8 @@ LM_SENSORS_ntv_code_to_bits( unsigned in
+ papi_vector_t _lmsensors_vector = {
+ 	.cmp_info = {
+ 				 /* default component information (unspecified values are initialized to 0) */
+-				 .name =
+-				 "$Id: linux-lmsensors.c,v 1.6 2012/02/10 19:58:08 terpstra Exp $",
+-				 .version = "$Revision: 1.6 $",
++				 .name = "linux-lmsensors.c",
++				 .version = "4.2.1",
+ 				 .num_mpx_cntrs = PAPI_MPX_DEF_DEG,
+ 				 .num_cntrs = LM_SENSORS_MAX_COUNTERS,
+ 				 .default_domain = PAPI_DOM_USER,
+@@ -489,5 +488,4 @@ papi_vector_t _lmsensors_vector = {
+ 	.ntv_enum_events = LM_SENSORS_ntv_enum_events,
+ 	.ntv_code_to_name = LM_SENSORS_ntv_code_to_name,
+ 	.ntv_code_to_bits = LM_SENSORS_ntv_code_to_bits,
+-	.ntv_bits_to_info = NULL,
+ };
+diff -up papi-4.2.1/src/components/lmsensors/linux-lmsensors.h.bz papi-4.2.1/src/components/lmsensors/linux-lmsensors.h
+--- papi-4.2.1/src/components/lmsensors/linux-lmsensors.h.bz	2012-02-09 10:02:53.000000000 -0500
++++ papi-4.2.1/src/components/lmsensors/linux-lmsensors.h	2012-03-09 15:57:31.393736053 -0500
+@@ -4,7 +4,7 @@
+ 
+ /** 
+  * @file    linux-lmsensors.h
+- * CVS:     $Id: linux-lmsensors.h,v 1.5 2012/02/09 15:02:53 jagode Exp $
++ * CVS:     $Id$
+  * @author  Daniel Lucio
+  * @author  Joachim Protze
+  * @author  Heike Jagode
diff --git a/papi.spec b/papi.spec
index 7dbf466..df7395f 100644
--- a/papi.spec
+++ b/papi.spec
@@ -1,11 +1,12 @@
 Summary: Performance Application Programming Interface
 Name: papi
 Version: 4.2.1
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: BSD
 Group: Development/System
 URL: http://icl.cs.utk.edu/papi/
 Source0: http://icl.cs.utk.edu/projects/papi/downloads/%{name}-%{version}.tar.gz
+Patch1: papi-bz797692.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 BuildRequires: ncurses-devel
 BuildRequires: gcc-gfortran
@@ -42,6 +43,7 @@ the PAPI userspace libraries and interfaces.
 
 %prep
 %setup -q
+%patch1 -p1 -b .bz
 
 %build
 cd src
@@ -100,6 +102,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/*.a
 
 %changelog
+* Fri Mar 9 2012 William Cohen <wcohen at redhat.com> - 4.2.1-2
+- Fix overrun in lmsensor component. (rhbz797692)
+
 * Tue Feb 14 2012 William Cohen <wcohen at redhat.com> - 4.2.1-1
 - Rebase to 4.2.1.
 


More information about the scm-commits mailing list