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>
#include "lib/util/sys_rw.h"
#include "lib/util/time.h"
#include "lib/util/tevent_unix.h"
#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"
#include "protocol/protocol.h"
#include "protocol/protocol_api.h"
TALLOC_CTX *mem_ctx;
struct tevent_context *ev;
struct ctdb_client_context *client;
TALLOC_CTX *mem_ctx;
struct tevent_context *ev;
struct ctdb_client_context *client;
struct tevent_req *req;
uint32_t generation;
struct tevent_req *req;
uint32_t generation;
write_fd = atoi(argv[1]);
sockpath = argv[2];
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) {
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {