Wireshark-dev: [Wireshark-dev] [PATCH] stats_tree.c fixup preventing segfault
From: Sebastien Tandel <[email protected]>
Date: Tue, 12 Dec 2006 04:41:19 +0100
Hi all,


   here is a patch against svn rev20122 which prevents wireshark from
segfault when trying the stats module "packet length".
the function affected is get_range in epan/stats_tree.c which did not
the correct tests if you want define range like the following :

"-" 
"10-"
"-10"
"0-10"
giving G_MININT (G_MAXINT) if the number is not defined to the left (right).


Sebastien Tandel
Index: epan/stats_tree.c
===================================================================
--- epan/stats_tree.c	(révision 20122)
+++ epan/stats_tree.c	(copie de travail)
@@ -530,12 +530,16 @@
 	
 	split =  g_strsplit(rngstr,"-",2);
 
-	rng->floor = strtol(split[0],NULL,10);
-	rng->ceil  = strtol(split[1],NULL,10);
+	if (*(split[0]) != '\0')
+	  rng->floor = strtol(split[0],NULL,10);
+	else
+	  rng->floor = G_MININT;
+
+	if (split[1] != NULL)
+	  rng->ceil  = strtol(split[1],NULL,10);
+	else
+	  rng->ceil = G_MAXINT;
 	
-	if (rng->ceil == 0) rng->ceil = G_MAXINT;
-	if (rng->floor == 0) rng->floor = G_MININT;
-
 	g_strfreev(split);
 	
 	return rng;