Index: include/ipmitool/helper.h
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/include/ipmitool/helper.h,v
retrieving revision 1.27
diff -u -r1.27 helper.h
--- include/ipmitool/helper.h	26 Jan 2012 10:04:04 -0000	1.27
+++ include/ipmitool/helper.h	26 Nov 2012 05:32:58 -0000
@@ -65,6 +65,7 @@
 const char * val2str(uint16_t val, const struct valstr * vs);
 const char * oemval2str(uint32_t oem,uint16_t val, const struct oemvalstr * vs);
 
+int str2double(const char * str, double * double_ptr);
 int str2long(const char * str, int64_t * lng_ptr);
 int str2ulong(const char * str, uint64_t * ulng_ptr);
 int str2int(const char * str, int32_t * int_ptr);
Index: lib/helper.c
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/lib/helper.c,v
retrieving revision 1.46
diff -u -r1.46 helper.c
--- lib/helper.c	26 Nov 2012 05:11:16 -0000	1.46
+++ lib/helper.c	26 Nov 2012 05:32:58 -0000
@@ -145,6 +145,33 @@
 	return un_str;
 }
 
+/* str2double - safely convert string to double
+ *
+ * @str: source string to convert from
+ * @double_ptr: pointer where to store result
+ *
+ * returns zero on success
+ * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow
+ */
+int str2double(const char * str, double * double_ptr)
+{
+	char * end_ptr = 0;
+	if (!str || !double_ptr)
+		return (-1);
+
+	*double_ptr = 0;
+	errno = 0;
+	*double_ptr = strtod(str, &end_ptr);
+
+	if (*end_ptr != '\0')
+		return (-2);
+
+	if (errno != 0)
+		return (-3);
+
+	return 0;
+} /* str2double(...) */
+
 /* str2long - safely convert string to int64_t
  *
  * @str: source string to convert from
Index: lib/ipmi_sensor.c
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/lib/ipmi_sensor.c,v
retrieving revision 1.44
diff -u -r1.44 ipmi_sensor.c
--- lib/ipmi_sensor.c	3 Aug 2012 17:07:07 -0000	1.44
+++ lib/ipmi_sensor.c	26 Nov 2012 05:32:58 -0000
@@ -46,6 +46,9 @@
 #define SCANNING_DISABLED	0x40
 #define READING_UNAVAILABLE	0x20
 #define	INVALID_THRESHOLD	"Invalid Threshold data values. Cannot Set Threshold Data."
+
+static int is_valid_setting(const char *input_param, double *double_ptr);
+
 // static
 int
 ipmi_sensor_get_sensor_reading_factors(
@@ -557,9 +560,15 @@
 			return -1;
 		}
 		allUpper = 1;
-		setting1 = (double) strtod(argv[2], NULL);
-		setting2 = (double) strtod(argv[3], NULL);
-		setting3 = (double) strtod(argv[4], NULL);
+
+		if (is_valid_setting(argv[2], &setting1) != 1)
+			return (-1);
+
+		if (is_valid_setting(argv[3], &setting2) != 1)
+			return (-1);
+
+		if (is_valid_setting(argv[4], &setting3) != 1)
+			return (-1);
 	} else if (strncmp(thresh, "lower", 5) == 0) {
 		if (argc < 5) {
 			lprintf(LOG_ERR,
@@ -567,9 +576,15 @@
 			return -1;
 		}
 		allLower = 1;
-		setting1 = (double) strtod(argv[2], NULL);
-		setting2 = (double) strtod(argv[3], NULL);
-		setting3 = (double) strtod(argv[4], NULL);
+
+		if (is_valid_setting(argv[2], &setting1) != 1)
+			return (-1);
+
+		if (is_valid_setting(argv[3], &setting2) != 1)
+			return (-1);
+
+		if (is_valid_setting(argv[4], &setting3) != 1)
+			return (-1);
 	} else {
 		setting1 = (double) atof(argv[2]);
 		if (strncmp(thresh, "unr", 3) == 0)
@@ -923,3 +938,26 @@
 
 	return rc;
 }
+
+/* is_valid_param - wrapper - convert user input string to double
+ *
+ * @input_param: string to convert from
+ * @double_ptr: pointer where to store converted value
+ *
+ * returns   0  if parameter is valid
+ * returns (-1) if parameter is invalid/on error
+ */
+static int
+is_valid_setting(const char *input_param, double *double_ptr)
+{
+	if (input_param == NULL) {
+		lprintf(LOG_ERROR, "ERROR: NULL pointer passed.");
+		return (-1);
+	}
+
+	if (str2double(input_param, double_ptr) == 0)
+		return 0;
+
+	lprintf(LOG_ERR, "Given setting \"%s\" is invalid.", input_param);
+	return (-1);
+} /* is_valid_setting(...) */
