From: Swen Schillig Date: Tue, 29 Jan 2019 12:07:56 +0000 (+0100) Subject: ctdb-server: Use wrapper for string to integer conversion X-Git-Tag: talloc-2.2.0~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55acae774a9994715043dfe6e7668c19f514c545;p=thirdparty%2Fsamba.git 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 Reviewed-by: Ralph Böhme Reviewed-by: Jeremy Allison --- 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) {