From: Swen Schillig Date: Wed, 30 Jan 2019 09:28:52 +0000 (+0100) Subject: ctdb-utils: Use wrapper for string to integer conversion X-Git-Tag: talloc-2.2.0~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa2c919e1d05a2033ce1cb41a86f8bdd789d68b8;p=thirdparty%2Fsamba.git ctdb-utils: 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/utils/ceph/ctdb_mutex_ceph_rados_helper.c b/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c index 7ef76c26e02..a43855008c0 100644 --- a/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c +++ b/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c @@ -301,10 +301,14 @@ int main(int argc, char *argv[]) cmr_state->pool_name = argv[3]; cmr_state->object = argv[4]; if (argc == 6) { + int error = 0; /* optional lock duration provided */ char *endptr = NULL; - cmr_state->lock_duration_s = strtoull(argv[5], &endptr, 0); - if ((endptr == argv[5]) || (*endptr != '\0')) { + cmr_state->lock_duration_s = strtoull_err(argv[5], + &endptr, + 0, + &error); + if ((endptr == argv[5]) || (*endptr != '\0') || (error != 0)) { fprintf(stdout, CTDB_MUTEX_STATUS_ERROR); ret = -EINVAL; goto err_ctx_cleanup;