diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index a949746d..310c4a52 100644 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -50,7 +50,7 @@ Device* Device::create(const char* name, const bool checkDevice, const bool read if (pos != NULL) { char* end = NULL; unsigned long int port = strtoul(pos+1, &end, 10); - if (end == NULL || *end != 0 || port < 1 || port > 65535) { + if (end == NULL || end == pos+1 || *end != 0 || port < 1 || port > 65535) { return NULL; // invalid port } struct sockaddr_in address; diff --git a/src/tools/ebusctl.cpp b/src/tools/ebusctl.cpp index 150e5b49..9d63a722 100644 --- a/src/tools/ebusctl.cpp +++ b/src/tools/ebusctl.cpp @@ -102,7 +102,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) break; case 'p': // --port=8888 port = strtoul(arg, &strEnd, 10); - if (strEnd == NULL || *strEnd != 0 || port < 1 || port > 65535) { + if (strEnd == NULL || strEnd == arg || *strEnd != 0 || port < 1 || port > 65535) { argp_error(state, "invalid port"); return EINVAL; } diff --git a/src/tools/ebusfeed.cpp b/src/tools/ebusfeed.cpp index 79c1d039..d1f532e8 100644 --- a/src/tools/ebusfeed.cpp +++ b/src/tools/ebusfeed.cpp @@ -102,7 +102,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) break; case 't': // --time=10000 opt->time = (unsigned int)strtoul(arg, &strEnd, 10); - if (strEnd == NULL || *strEnd != 0 || opt->time < 1000 || opt->time > 100000000) { + if (strEnd == NULL || strEnd == arg || *strEnd != 0 || opt->time < 1000 || opt->time > 100000000) { argp_error(state, "invalid time"); return EINVAL; }