diff options
author | Swen Schillig <swen@linux.ibm.com> | 2019-01-29 13:07:56 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-03-01 00:32:11 +0000 |
commit | 55acae774a9994715043dfe6e7668c19f514c545 (patch) | |
tree | 6fc1e018309ce6d8ea71d5c0b1b5206af07af610 /ctdb/server/ctdb_recovery_helper.c | |
parent | e96bccc879a675856b3a875db2d718445410caea (diff) | |
download | samba-55acae774a9994715043dfe6e7668c19f514c545.tar.gz |
ctdb-server: Use wrapper for string to integer conversion
In order to detect an value overflow error during
the string to integer conversion with strtoul/strtoull,
the errno variable must be set to zero before the execution and
checked after the conversion is performed. This is achieved by
using the wrapper function strtoul_err and strtoull_err.
Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'ctdb/server/ctdb_recovery_helper.c')
-rw-r--r-- | ctdb/server/ctdb_recovery_helper.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c index 7fdcc2e5a29..57e12b47037 100644 --- a/ctdb/server/ctdb_recovery_helper.c +++ b/ctdb/server/ctdb_recovery_helper.c @@ -30,6 +30,7 @@ #include "lib/util/sys_rw.h" #include "lib/util/time.h" #include "lib/util/tevent_unix.h" +#include "lib/util/util.h" #include "protocol/protocol.h" #include "protocol/protocol_api.h" @@ -2739,7 +2740,7 @@ int main(int argc, char *argv[]) TALLOC_CTX *mem_ctx; struct tevent_context *ev; struct ctdb_client_context *client; - int ret; + int ret = 0; struct tevent_req *req; uint32_t generation; @@ -2750,7 +2751,11 @@ int main(int argc, char *argv[]) write_fd = atoi(argv[1]); sockpath = argv[2]; - generation = (uint32_t)strtoul(argv[3], NULL, 0); + generation = (uint32_t)strtoul_err(argv[3], NULL, 0, &ret); + if (ret != 0) { + fprintf(stderr, "recovery: unable to initialize generation\n"); + goto failed; + } mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { |