diff options
author | Swen Schillig <swen@linux.ibm.com> | 2019-01-28 13:36:45 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-03-01 00:32:10 +0000 |
commit | e82228f2e09d66807d0bce150bb1db9731bbd4d4 (patch) | |
tree | dcc2fc9cebf864634b1290ef92e99528e5a49295 /source3/utils/net_sam.c | |
parent | fef2a7ca0a87dc3de25480b8070f8090d5f1cb09 (diff) | |
download | samba-e82228f2e09d66807d0bce150bb1db9731bbd4d4.tar.gz |
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 'source3/utils/net_sam.c')
-rw-r--r-- | source3/utils/net_sam.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index 5a9d1792d51..fc2a7baacef 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -484,6 +484,7 @@ static int net_sam_policy_set(struct net_context *c, int argc, const char **argv uint32_t old_value = 0; enum pdb_policy_type field; char *endptr; + int err = 0; if (argc != 2 || c->display_usage) { d_fprintf(stderr, "%s\n%s", @@ -500,9 +501,9 @@ static int net_sam_policy_set(struct net_context *c, int argc, const char **argv value = -1; } else { - value = strtoul(argv[1], &endptr, 10); + value = strtoul_err(argv[1], &endptr, 10, &err); - if ((endptr == argv[1]) || (endptr[0] != '\0')) { + if ((endptr == argv[1]) || (endptr[0] != '\0') || (err != 0)) { d_printf(_("Unable to set policy \"%s\"! Invalid value " "\"%s\".\n"), account_policy, argv[1]); |