common-lib: Update error check for new string conversion wrapper
authorSwen Schillig <swen@linux.ibm.com>
Wed, 6 Mar 2019 09:02:53 +0000 (10:02 +0100)
committerChristof Schmitt <cs@samba.org>
Thu, 11 Apr 2019 22:29:27 +0000 (22:29 +0000)
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 <swen@linux.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
lib/ldb-samba/ldb_matching_rules.c
lib/util/access.c
lib/util/util_str.c

index 7387c12f10d89dd3132081d1ed096ef754ff6fdd..0754e7e066be3df2ca98613a992ccca061320154 100644 (file)
@@ -393,12 +393,7 @@ static int dsdb_match_for_dns_to_tombstone_time(struct ldb_context *ldb,
                        return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
                }
                tombstone_time = strtoull_err(s, &p, 10, &error);
-               if (p == NULL ||
-                   p == s ||
-                   *p != '\0' ||
-                   error != 0 ||
-                   tombstone_time == ULLONG_MAX)
-               {
+               if (error != 0 || *p != '\0') {
                        DBG_ERR("Invalid timestamp string passed\n");
                        return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
                }
@@ -529,12 +524,7 @@ static int dsdb_match_for_expunge(struct ldb_context *ldb,
                        return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
                }
                tombstone_time = strtoull_err(s, &p, 10, &error);
-               if (p == NULL ||
-                   p == s ||
-                   *p != '\0' ||
-                   error != 0 ||
-                   tombstone_time == ULLONG_MAX)
-               {
+               if (error != 0 || *p != '\0') {
                        return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
                }
        }
index a05a47c15b20070998e6b50f3b9cfe29e2757c27..960fe4b066cad6197ccbdad7aefdd730911bb753 100644 (file)
@@ -75,7 +75,7 @@ static bool masked_match(const char *tok, const char *slash, const char *s)
                unsigned long val;
 
                val = strtoul_err(slash+1, &endp, 0, &error);
-               if (slash+1 == endp || (endp && *endp != '\0') || error != 0) {
+               if (error != 0 || *endp != '\0') {
                        return false;
                }
                if (!make_netmask(&ss_mask, &ss_tok, val)) {
index 447919b087bbac5be79ca8c3bb8f2ff8702795f2..29a44836bdea4f5e6af6918280ee6909778bf85b 100644 (file)
@@ -70,7 +70,7 @@ _PUBLIC_ bool conv_str_size_error(const char * str, uint64_t * val)
        }
 
        lval = strtoull_err(str, &end, 10, &error);
-       if (end == NULL || end == str || error != 0) {
+       if (error != 0) {
                return false;
        }
 
@@ -112,7 +112,7 @@ _PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val)
        }
 
        lval = strtoull_err(str, &end, 10, &error);
-       if (end == NULL || *end != '\0' || end == str || error != 0) {
+       if (error != 0 || *end != '\0') {
                return false;
        }