Skip to content

Commit

Permalink
ctdb-server: Use wrapper for string to integer conversion
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ralph Böhme <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
sswen authored and jrasamba committed Mar 1, 2019
1 parent e96bccc commit 55acae7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ctdb/server/ctdb_recovery_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down

0 comments on commit 55acae7

Please sign in to comment.