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