diff options
author | Swen Schillig <swen@linux.ibm.com> | 2019-01-30 10:28:52 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-03-01 00:32:11 +0000 |
commit | fa2c919e1d05a2033ce1cb41a86f8bdd789d68b8 (patch) | |
tree | 20afced76c05cdc9277c3eb25726c2f4a7492737 /ctdb/utils | |
parent | 2b2ff12e706d999ff2d84affa79c64b33cc289a7 (diff) | |
download | samba-fa2c919e1d05a2033ce1cb41a86f8bdd789d68b8.tar.gz |
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 <swen@linux.ibm.com>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'ctdb/utils')
-rw-r--r-- | ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c | 8 |
1 files changed, 6 insertions, 2 deletions
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; |