From: Swen Schillig Date: Wed, 6 Mar 2019 08:29:13 +0000 (+0100) Subject: utils: Update error check for new string conversion wrapper X-Git-Tag: tdb-1.4.1~455 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ca4b1f6d9bbd60b0e0d074221373aff27b0bdc2;p=thirdparty%2Fsamba.git utils: Update error check for new string conversion wrapper The new string conversion wrappers detect and flag errors which occured during the string to integer conversion. Those modifications required an update of the callees error checks. Signed-off-by: Swen Schillig Reviewed-by: Ralph Boehme Reviewed-by: Christof Schmitt --- diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index f6c9f3a1a3d..d1a6db95921 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -631,16 +631,10 @@ static bool parse_uint32(const char *str, uint32_t *result) int error = 0; val = strtoul_err(str, &endptr, 10, &error); - - if (str == endptr) { - return false; - } - if (*endptr != '\0') { - return false; - } - if (error != 0) { + if (error != 0 || *endptr != '\0') { return false; } + *result = val; /* Potential crop */ return true; } diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index fc2a7baacef..164d9408c56 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -503,7 +503,7 @@ static int net_sam_policy_set(struct net_context *c, int argc, const char **argv else { value = strtoul_err(argv[1], &endptr, 10, &err); - if ((endptr == argv[1]) || (endptr[0] != '\0') || (err != 0)) { + if (err != 0 || *endptr != '\0') { d_printf(_("Unable to set policy \"%s\"! Invalid value " "\"%s\".\n"), account_policy, argv[1]); diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index c80d5411b00..462c753217e 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -602,10 +602,7 @@ static int set_user_info(const char *username, const char *fullname, uint32_t num; num = strtoul_err(kickoff_time, &endptr, 10, &error); - if ((endptr == kickoff_time) || - (endptr[0] != '\0') || - (error != 0)) - { + if (error != 0 || *endptr != '\0') { fprintf(stderr, "Failed to parse kickoff time\n"); return -1; } diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c index aeea70ac22e..7dd9f0fadea 100644 --- a/source3/utils/regedit_dialog.c +++ b/source3/utils/regedit_dialog.c @@ -1029,7 +1029,6 @@ bool dialog_section_text_field_get_int(struct dialog_section *section, bool dialog_section_text_field_get_uint(struct dialog_section *section, unsigned long long *out) { - bool rv; const char *buf; char *endp; int error = 0; @@ -1043,12 +1042,11 @@ bool dialog_section_text_field_get_uint(struct dialog_section *section, return false; } *out = strtoull_err(buf, &endp, 0, &error); - rv = true; - if (endp == buf || endp == NULL || endp[0] != '\0' || error != 0) { - rv = false; + if (error != 0 || *endp != '\0') { + return false; } - return rv; + return true; } /* hex editor field */