From 3bc973c6022ee79f57459849bc5c104795897fde Mon Sep 17 00:00:00 2001 From: Swen Schillig Date: Tue, 4 Jun 2019 09:06:37 +0200 Subject: [PATCH] source4: Update all consumers of strtoul_err(), strtoull_err() to new API Signed-off-by: Swen Schillig Reviewed-by: Ralph Boehme Reviewed-by: Christof Schmitt --- source4/dns_server/dlz_bind9.c | 2 +- source4/dsdb/common/dsdb_dn.c | 2 +- source4/dsdb/common/util.c | 6 +++--- source4/dsdb/samdb/ldb_modules/dirsync.c | 5 +++-- source4/dsdb/samdb/ldb_modules/partition_metadata.c | 2 +- source4/dsdb/samdb/ldb_modules/samldb.c | 6 +++--- source4/dsdb/samdb/ldb_modules/schema_load.c | 6 +++++- source4/dsdb/schema/schema_prefixmap.c | 2 +- source4/lib/registry/ldb.c | 12 ++++++++++-- source4/lib/socket/interface.c | 9 ++++++--- source4/libcli/resolve/dns_ex.c | 2 +- source4/nbt_server/wins/winsdb.c | 5 +++-- source4/rpc_server/lsa/dcesrv_lsa.c | 5 +++-- source4/torture/nbench/nbench.c | 6 +++++- source4/torture/smb2/sharemode.c | 2 +- 15 files changed, 47 insertions(+), 25 deletions(-) diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c index 5db1131e4dd..872eb3e0c1f 100644 --- a/source4/dns_server/dlz_bind9.c +++ b/source4/dns_server/dlz_bind9.c @@ -341,7 +341,7 @@ static bool b9_dns_type(const char *type, enum dns_record_type *dtype) char *istr = strtok_r(str, sep, &saveptr); \ int error = 0;\ if ((istr) == NULL) return false; \ - (ret) = strtoul_err(istr, NULL, 10, &error); \ + (ret) = smb_strtoul(istr, NULL, 10, &error, SMB_STR_STANDARD); \ if (error != 0) {\ return false;\ }\ diff --git a/source4/dsdb/common/dsdb_dn.c b/source4/dsdb/common/dsdb_dn.c index 2119a4faaf3..fd009a7af98 100644 --- a/source4/dsdb/common/dsdb_dn.c +++ b/source4/dsdb/common/dsdb_dn.c @@ -135,7 +135,7 @@ struct dsdb_dn *dsdb_dn_parse_trusted(TALLOC_CTX *mem_ctx, struct ldb_context *l } errno = 0; - blen = strtoul_err(p1, &p2, 10, &error); + blen = smb_strtoul(p1, &p2, 10, &error, SMB_STR_STANDARD); if (error != 0) { DEBUG(10, (__location__ ": failed\n")); goto failed; diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index a38f5061e7d..e521ed09999 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -3845,7 +3845,7 @@ NTSTATUS dsdb_get_extended_dn_uint64(struct ldb_dn *dn, uint64_t *val, const cha memcpy(s, v->data, v->length); s[v->length] = 0; - *val = strtoull_err(s, NULL, 0, &error); + *val = smb_strtoull(s, NULL, 0, &error, SMB_STR_STANDARD); if (error != 0) { return NT_STATUS_INVALID_PARAMETER; } @@ -3881,7 +3881,7 @@ NTSTATUS dsdb_get_extended_dn_uint32(struct ldb_dn *dn, uint32_t *val, const cha char s[v->length + 1]; memcpy(s, v->data, v->length); s[v->length] = 0; - *val = strtoul_err(s, NULL, 0, &error); + *val = smb_strtoul(s, NULL, 0, &error, SMB_STR_STANDARD); if (error != 0) { return NT_STATUS_INVALID_PARAMETER; } @@ -3947,7 +3947,7 @@ uint32_t dsdb_dn_val_rmd_flags(const struct ldb_val *val) if (!p) { return 0; } - flags = strtoul_err(p+11, &end, 10, &error); + flags = smb_strtoul(p+11, &end, 10, &error, SMB_STR_STANDARD); if (!end || *end != '>' || error != 0) { /* it must end in a > */ return 0; diff --git a/source4/dsdb/samdb/ldb_modules/dirsync.c b/source4/dsdb/samdb/ldb_modules/dirsync.c index 74a107c8476..00f24bd6d59 100644 --- a/source4/dsdb/samdb/ldb_modules/dirsync.c +++ b/source4/dsdb/samdb/ldb_modules/dirsync.c @@ -161,11 +161,12 @@ static int dirsync_filter_entry(struct ldb_request *req, * to update the max USN in the cookie if we * decide to keep this entry */ - val = strtoull_err( + val = smb_strtoull( (const char*)msg->elements[i].values[0].data, NULL, 0, - &error); + &error, + SMB_STR_STANDARD); if (error != 0) { ldb_set_errstring(ldb, "Failed to convert USN"); diff --git a/source4/dsdb/samdb/ldb_modules/partition_metadata.c b/source4/dsdb/samdb/ldb_modules/partition_metadata.c index 349f79c2645..44ce2c66639 100644 --- a/source4/dsdb/samdb/ldb_modules/partition_metadata.c +++ b/source4/dsdb/samdb/ldb_modules/partition_metadata.c @@ -74,7 +74,7 @@ static int partition_metadata_get_uint64(struct ldb_module *module, return ldb_module_oom(module); } - *value = strtoull_err(value_str, NULL, 10, &error); + *value = smb_strtoull(value_str, NULL, 10, &error, SMB_STR_STANDARD); if (error != 0) { return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR, "partition_metadata: converision failed"); diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 094f254c8fc..4da8564c77a 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -3305,7 +3305,7 @@ static int check_address_roundtrip(const char *address, int family, */ static int verify_cidr(const char *cidr) { - char *address = NULL, *slash = NULL, *endptr = NULL; + char *address = NULL, *slash = NULL; bool has_colon, has_dot; int res, ret; unsigned long mask; @@ -3330,14 +3330,14 @@ static int verify_cidr(const char *cidr) /* terminate the address for strchr, inet_pton */ *slash = '\0'; - mask = strtoul_err(slash + 1, &endptr, 10, &error); + mask = smb_strtoul(slash + 1, NULL, 10, &error, SMB_STR_FULL_STR_CONV); if (mask == 0){ DBG_INFO("Windows does not like the zero mask, " "so nor do we: %s\n", cidr); goto error; } - if (error != 0 || *endptr != '\0'){ + if (error != 0){ DBG_INFO("CIDR mask is not a proper integer: %s\n", cidr); goto error; } diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c index 3b0781685cf..40ea42b55e4 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_load.c +++ b/source4/dsdb/samdb/ldb_modules/schema_load.c @@ -170,7 +170,11 @@ static int schema_metadata_get_uint64(struct schema_load_private_data *data, * next time */ data->tdb_seqnum = tdb_seqnum; - data->schema_seq_num_cache = strtoull_err(value_str, NULL, 10, &error); + data->schema_seq_num_cache = smb_strtoull(value_str, + NULL, + 10, + &error, + SMB_STR_STANDARD); if (error != 0) { talloc_free(tmp_ctx); return ldb_module_error(data->module, LDB_ERR_OPERATIONS_ERROR, diff --git a/source4/dsdb/schema/schema_prefixmap.c b/source4/dsdb/schema/schema_prefixmap.c index 482a35f2165..706e48a034e 100644 --- a/source4/dsdb/schema/schema_prefixmap.c +++ b/source4/dsdb/schema/schema_prefixmap.c @@ -224,7 +224,7 @@ static WERROR _dsdb_pfm_make_binary_oid(const char *full_oid, TALLOC_CTX *mem_ct return WERR_INVALID_PARAMETER; } oid_subid++; - last_subid = strtoul_err(oid_subid, NULL, 10, &error); + last_subid = smb_strtoul(oid_subid, NULL, 10, &error, SMB_STR_STANDARD); if (error != 0) { return WERR_INVALID_PARAMETER; } diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index d0e9f46f4e1..c0b13e0d4ce 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -79,7 +79,11 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, /* The data is a plain DWORD */ uint32_t tmp; - tmp = strtoul_err((char *)val->data, NULL, 0, &error); + tmp = smb_strtoul((char *)val->data, + NULL, + 0, + &error, + SMB_STR_STANDARD); if (error != 0) { data->data = NULL; data->length = 0; @@ -102,7 +106,11 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, /* The data is a plain QWORD */ uint64_t tmp; - tmp = strtoull_err((char *)val->data, NULL, 0, &error); + tmp = smb_strtoull((char *)val->data, + NULL, + 0, + &error, + SMB_STR_STANDARD); if (error != 0) { data->data = NULL; data->length = 0; diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c index 9bf002c2f01..93b60f7d32f 100644 --- a/source4/lib/socket/interface.c +++ b/source4/lib/socket/interface.c @@ -224,11 +224,14 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, return; } } else { - char *endp = NULL; int error = 0; - unsigned long val = strtoul_err(p, &endp, 0, &error); - if (error != 0 || *endp != '\0') { + unsigned long val = smb_strtoul(p, + NULL, + 0, + &error, + SMB_STR_FULL_STR_CONV); + if (error != 0) { DEBUG(2,("interpret_interface: " "can't determine netmask value from %s\n", p)); diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c index 86eeb5f5921..9ee19ffb4fd 100644 --- a/source4/libcli/resolve/dns_ex.c +++ b/source4/libcli/resolve/dns_ex.c @@ -536,7 +536,7 @@ static void pipe_handler(struct tevent_context *ev, struct tevent_fd *fde, composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND); return; } - port = strtoul_err(p, NULL, 10, &error); + port = smb_strtoul(p, NULL, 10, &error, SMB_STR_STANDARD); if (port > UINT16_MAX || error != 0) { composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND); return; diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index 5184d7de7b0..41a9fd8550d 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -183,11 +183,12 @@ static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct n if (comp_num > cur && strcasecmp("type", ldb_dn_get_component_name(dn, cur)) == 0) { name->type = - strtoul_err( + smb_strtoul( (char *)ldb_dn_get_component_val(dn, cur)->data, NULL, 0, - &error); + &error, + SMB_STR_STANDARD); if (error != 0) { status = NT_STATUS_INTERNAL_DB_CORRUPTION; goto failed; diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 3e83214458d..831ebf42e36 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -1736,10 +1736,11 @@ static NTSTATUS update_uint32_t_value(TALLOC_CTX *mem_ctx, flags = LDB_FLAG_MOD_ADD; } else { - orig_uint = strtoul_err((const char *)orig_val->data, + orig_uint = smb_strtoul((const char *)orig_val->data, NULL, 0, - &error); + &error, + SMB_STR_STANDARD); if (error != 0 || orig_uint != value) { /* replace also if can't get value */ flags = LDB_FLAG_MOD_REPLACE; diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c index 83395123c33..6e2dbe0b907 100644 --- a/source4/torture/nbench/nbench.c +++ b/source4/torture/nbench/nbench.c @@ -140,7 +140,11 @@ again: /* accept numeric or string status codes */ if (strncmp(params[i-1], "0x", 2) == 0) { - tmp = strtoul_err(params[i-1], NULL, 16, &error); + tmp = smb_strtoul(params[i-1], + NULL, + 16, + &error, + SMB_STR_STANDARD); if (error != 0) { tmp = error; } diff --git a/source4/torture/smb2/sharemode.c b/source4/torture/smb2/sharemode.c index c28e6b86dc5..5b1b8c4afba 100644 --- a/source4/torture/smb2/sharemode.c +++ b/source4/torture/smb2/sharemode.c @@ -192,7 +192,7 @@ bool torture_smb2_check_sharemode(struct torture_context *tctx) sharemode = smb2_util_share_access(sharemode_string); access_string = torture_setting_string(tctx, "access", "0xf01ff"); - access = strtoul_err(access_string, NULL, 0, &error); + access = smb_strtoul(access_string, NULL, 0, &error, SMB_STR_STANDARD); if (error != 0) { torture_comment(tctx, "Initializing access failed.\n"); return false; -- 2.34.1