[netfilter-cvslog] r3737 - trunk/nfsim/tools

kadlec at netfilter.org kadlec at netfilter.org
Tue Feb 22 11:50:19 CET 2005


Author: kadlec at netfilter.org
Date: 2005-02-22 11:50:19 +0100 (Tue, 22 Feb 2005)
New Revision: 3737

Modified:
   trunk/nfsim/tools/gen_ip.c
   trunk/nfsim/tools/gen_ip.h
Log:
Two gen_ip related fix applied (JK)


Modified: trunk/nfsim/tools/gen_ip.c
===================================================================
--- trunk/nfsim/tools/gen_ip.c	2005-02-22 10:26:12 UTC (rev 3736)
+++ trunk/nfsim/tools/gen_ip.c	2005-02-22 10:50:19 UTC (rev 3737)
@@ -56,13 +56,13 @@
 	{0}
 };
 
-int string_to_number(const char *s, int min, int max)
+unsigned int string_to_number(const char *s, unsigned int min, unsigned int max)
 {
-	int number;
+	unsigned int number;
 	char *end;
 
 	/* Handle hex, octal, etc. */
-	number = (int)strtol(s, &end, 0);
+	number = (unsigned int)strtoul(s, &end, 0);
 	if (*end == '\0' && end != s) {
 		/* we parsed a number, let's see if we want this */
 		if (min <= number && number <= max)
@@ -394,11 +394,13 @@
 	size_t i;
 
 	/* Options are simple comma-separated number list. */
-	for (i = 0, tok=strtok(opts, ","); tok; tok=strtok(NULL, ","), i++)
+	for (i = 0, tok=strtok(opts, ","); 
+	     tok && i < sizeof(options);
+	     tok=strtok(NULL, ","), i++)
 		options[i] = atol(tok);
 
-	if (i >= sizeof(options)) {
-		nfsim_log(LOG_UI, "Too many TCP options `%s'", opts);
+	if (tok) {
+		nfsim_log(LOG_UI, "Too many TCP options: %s", opts);
 		return 1;
 	}
 	if (i % 4 != 0) {
@@ -413,9 +415,9 @@
 static int
 parse_tcpnumber(const char *number, u_int32_t *val)
 {
-	int i;
+	unsigned int i;
 
-	i = string_to_number(number, 0, INT_MAX);
+	i = string_to_number(number, 0, UINT_MAX);
 	if (i < 0) {
 		nfsim_log(LOG_UI, "Invalid tcp number `%s'", number);
 		return 1;

Modified: trunk/nfsim/tools/gen_ip.h
===================================================================
--- trunk/nfsim/tools/gen_ip.h	2005-02-22 10:26:12 UTC (rev 3736)
+++ trunk/nfsim/tools/gen_ip.h	2005-02-22 10:50:19 UTC (rev 3737)
@@ -25,7 +25,7 @@
 		 char *dump_flags);
 
 /* Convert string to number in this range: -1 for fail. */
-int string_to_number(const char *s, int min, int max);
+unsigned int string_to_number(const char *s, unsigned int min, unsigned int max);
 
 /* Convert string of form w.x.y.z to an address.  NULL on fail. */
 struct in_addr *dotted_to_addr(const char *dotted);




More information about the netfilter-cvslog mailing list