Blame SOURCES/bz1393958-cleanup_numeric_argument_parsing.patch

bdb0eb
diff -ur a/client/options.c b/client/options.c
bdb0eb
--- a/client/options.c	2017-03-13 17:48:52.083747432 -0400
bdb0eb
+++ b/client/options.c	2017-03-13 17:50:37.289128784 -0400
bdb0eb
@@ -130,14 +130,18 @@
bdb0eb
 static inline void
bdb0eb
 assign_port(fence_virt_args_t *args, struct arg_info *arg, char *value)
bdb0eb
 {
bdb0eb
+	char *p;
bdb0eb
+	int ret;
bdb0eb
+
bdb0eb
 	if (!value)
bdb0eb
 		return;
bdb0eb
 
bdb0eb
-	args->net.port = atoi(value);
bdb0eb
-	if (args->net.port <= 0 || args->net.port >= 65536) {
bdb0eb
+	ret = strtol(value, &p, 0);
bdb0eb
+	if (ret <= 0 || ret >= 65536 || *p != '\0') {
bdb0eb
 		printf("Invalid port: '%s'\n", value);
bdb0eb
 		args->flags |= F_ERR;
bdb0eb
-	}
bdb0eb
+	} else
bdb0eb
+		args->net.port = ret;
bdb0eb
 }
bdb0eb
 
bdb0eb
 
bdb0eb
@@ -154,14 +158,18 @@
bdb0eb
 static inline void
bdb0eb
 assign_retrans(fence_virt_args_t *args, struct arg_info *arg, char *value)
bdb0eb
 {
bdb0eb
+	char *p;
bdb0eb
+	int ret;
bdb0eb
+
bdb0eb
 	if (!value)
bdb0eb
 		return;
bdb0eb
 
bdb0eb
-	args->retr_time = atoi(value);
bdb0eb
-	if (args->retr_time <= 0) {
bdb0eb
+	ret = strtol(value, &p, 0);
bdb0eb
+	if (ret <= 0 || *p != '\0') {
bdb0eb
 		printf("Invalid retransmit time: '%s'\n", value);
bdb0eb
 		args->flags |= F_ERR;
bdb0eb
-	}
bdb0eb
+	} else
bdb0eb
+		args->retr_time = ret;
bdb0eb
 }
bdb0eb
 
bdb0eb
 static inline void
bdb0eb
@@ -319,27 +327,35 @@
bdb0eb
 static inline void
bdb0eb
 assign_timeout(fence_virt_args_t *args, struct arg_info *arg, char *value)
bdb0eb
 {
bdb0eb
+	char *p;
bdb0eb
+	int ret;
bdb0eb
+
bdb0eb
 	if (!value)
bdb0eb
 		return;
bdb0eb
 
bdb0eb
-	args->timeout = atoi(value);
bdb0eb
-	if (args->timeout <= 0) {
bdb0eb
+	ret = strtol(value, &p, 0);
bdb0eb
+	if (ret <= 0 || *p != '\0') {
bdb0eb
 		printf("Invalid timeout: '%s'\n", value);
bdb0eb
 		args->flags |= F_ERR;
bdb0eb
-	}
bdb0eb
+	} else
bdb0eb
+		args->timeout = ret;
bdb0eb
 }
bdb0eb
 
bdb0eb
 static inline void
bdb0eb
 assign_delay(fence_virt_args_t *args, struct arg_info *arg, char *value)
bdb0eb
 {
bdb0eb
+	char *p;
bdb0eb
+	int ret;
bdb0eb
+
bdb0eb
 	if (!value)
bdb0eb
 		return;
bdb0eb
 
bdb0eb
-	args->delay = atoi(value);
bdb0eb
-	if (args->delay <= 0) {
bdb0eb
+	ret = strtol(value, &p, 0);
bdb0eb
+	if (ret < 0 || *p != '\0') {
bdb0eb
 		printf("Invalid delay: '%s'\n", value);
bdb0eb
 		args->flags |= F_ERR;
bdb0eb
-	}
bdb0eb
+	} else
bdb0eb
+		args->delay = ret;
bdb0eb
 }
bdb0eb
 
bdb0eb
 static inline void
bdb0eb
diff -ur a/server/config.c b/server/config.c
bdb0eb
--- a/server/config.c	2017-03-13 17:48:52.081747462 -0400
bdb0eb
+++ b/server/config.c	2017-03-13 17:49:08.526494450 -0400
bdb0eb
@@ -237,9 +237,10 @@
bdb0eb
 
bdb0eb
 	do {
bdb0eb
 		text_input("Multicast IP Port", val, inp, sizeof(inp));
bdb0eb
+		char *p;
bdb0eb
 
bdb0eb
-		done = atoi(inp);
bdb0eb
-		if (done <= 0 || done >= 65536) {
bdb0eb
+		done = strtol(inp, &p, 0);
bdb0eb
+		if (*p != '\0' || done <= 0 || done >= 65536) {
bdb0eb
 			printf("Port value '%s' is out of range\n", val);
bdb0eb
 			continue;
bdb0eb
 		}
bdb0eb
@@ -374,9 +375,10 @@
bdb0eb
 
bdb0eb
 	do {
bdb0eb
 		text_input("TCP Listen Port", val, inp, sizeof(inp));
bdb0eb
+		char *p;
bdb0eb
 
bdb0eb
-		done = atoi(inp);
bdb0eb
-		if (done <= 0 || done != (done & 0xffff)) {
bdb0eb
+		done = strtol(inp, &p, 0);
bdb0eb
+		if (*p != '\0' || done <= 0 || done >= 65536) {
bdb0eb
 			printf("Port value '%s' is out of range\n", val);
bdb0eb
 			continue;
bdb0eb
 		}