Skip to content

Commit

Permalink
common-lib: Update error check for new string conversion wrapper
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
Reviewed-by: Christof Schmitt <[email protected]>
  • Loading branch information
sswen authored and chs committed Apr 11, 2019
1 parent 6c1068a commit 6461a99
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
14 changes: 2 additions & 12 deletions lib/ldb-samba/ldb_matching_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/util/util_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 6461a99

Please sign in to comment.