#define DNS_PARSE_UINT(ret, str, sep, saveptr) do { \
char *istr = strtok_r(str, sep, &saveptr); \
+ int error = 0;\
if ((istr) == NULL) return false; \
- (ret) = strtoul(istr, NULL, 10); \
+ (ret) = strtoul_err(istr, NULL, 10, &error); \
+ if (error != 0) {\
+ return false;\
+ }\
} while (0)
/*
struct ldb_val bval;
struct ldb_val dval;
char *dn_str;
+ int error = 0;
enum dsdb_dn_format dn_format = dsdb_dn_oid_to_format(dn_oid);
}
errno = 0;
- blen = strtoul(p1, &p2, 10);
- if (errno != 0) {
+ blen = strtoul_err(p1, &p2, 10, &error);
+ if (error != 0) {
DEBUG(10, (__location__ ": failed\n"));
goto failed;
}
NTSTATUS dsdb_get_extended_dn_uint64(struct ldb_dn *dn, uint64_t *val, const char *component_name)
{
const struct ldb_val *v;
+ int error = 0;
v = ldb_dn_get_extended_component(dn, component_name);
if (v == NULL) {
memcpy(s, v->data, v->length);
s[v->length] = 0;
- *val = strtoull(s, NULL, 0);
+ *val = strtoull_err(s, NULL, 0, &error);
+ if (error != 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
}
return NT_STATUS_OK;
}
NTSTATUS dsdb_get_extended_dn_uint32(struct ldb_dn *dn, uint32_t *val, const char *component_name)
{
const struct ldb_val *v;
+ int error = 0;
v = ldb_dn_get_extended_component(dn, component_name);
if (v == NULL) {
char s[v->length + 1];
memcpy(s, v->data, v->length);
s[v->length] = 0;
- *val = strtoul(s, NULL, 0);
+ *val = strtoul_err(s, NULL, 0, &error);
+ if (error != 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
}
return NT_STATUS_OK;
const char *p;
uint32_t flags;
char *end;
+ int error = 0;
if (val->length < 13) {
return 0;
if (!p) {
return 0;
}
- flags = strtoul(p+11, &end, 10);
- if (!end || *end != '>') {
+ flags = strtoul_err(p+11, &end, 10, &error);
+ if (!end || *end != '>' || error != 0) {
/* it must end in a > */
return 0;
}
for (i = msg->num_elements - 1; i >= 0; i--) {
attr = dsdb_attribute_by_lDAPDisplayName(dsc->schema, msg->elements[i].name);
if (ldb_attr_cmp(msg->elements[i].name, "uSNChanged") == 0) {
+ int error = 0;
/* Read the USN it will used at the end of the filtering
* to update the max USN in the cookie if we
* decide to keep this entry
*/
- val = strtoull((const char*)msg->elements[i].values[0].data, NULL, 0);
+ val = strtoull_err(
+ (const char*)msg->elements[i].values[0].data,
+ NULL,
+ 0,
+ &error);
+ if (error != 0) {
+ ldb_set_errstring(ldb,
+ "Failed to convert USN");
+ return ldb_module_done(dsc->req,
+ NULL,
+ NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
continue;
}
TDB_DATA tdb_key, tdb_data;
char *value_str;
TALLOC_CTX *tmp_ctx;
+ int error = 0;
data = talloc_get_type_abort(ldb_module_get_private(module),
struct partition_private_data);
return ldb_module_oom(module);
}
- *value = strtoull(value_str, NULL, 10);
+ *value = strtoull_err(value_str, NULL, 10, &error);
+ if (error != 0) {
+ return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
+ "partition_metadata: converision failed");
+ }
SAFE_FREE(tdb_data.dptr);
talloc_free(tmp_ctx);
char *address_redux = NULL;
unsigned int address_len;
TALLOC_CTX *frame = NULL;
+ int error = 0;
DBG_DEBUG("CIDR is %s\n", cidr);
frame = talloc_stackframe();
/* terminate the address for strchr, inet_pton */
*slash = '\0';
- mask = strtoul(slash + 1, &endptr, 10);
+ mask = strtoul_err(slash + 1, &endptr, 10, &error);
if (mask == 0){
DBG_INFO("Windows does not like the zero mask, "
"so nor do we: %s\n", cidr);
goto error;
}
- if (*endptr != '\0' || endptr == slash + 1){
+ if (*endptr != '\0' || endptr == slash + 1 || error != 0){
DBG_INFO("CIDR mask is not a proper integer: %s\n", cidr);
goto error;
}
char *value_str;
TALLOC_CTX *tmp_ctx;
int tdb_seqnum;
+ int error = 0;
if (!data) {
*value = default_value;
* next time
*/
data->tdb_seqnum = tdb_seqnum;
- data->schema_seq_num_cache = strtoull(value_str, NULL, 10);
+ data->schema_seq_num_cache = strtoull_err(value_str, NULL, 10, &error);
+ if (error != 0) {
+ talloc_free(tmp_ctx);
+ return ldb_module_error(data->module, LDB_ERR_OPERATIONS_ERROR,
+ "Failed to convert value");
+ }
*value = data->schema_seq_num_cache;
{
uint32_t last_subid;
const char *oid_subid;
+ int error = 0;
/* make last sub-identifier value */
oid_subid = strrchr(full_oid, '.');
return WERR_INVALID_PARAMETER;
}
oid_subid++;
- last_subid = strtoul(oid_subid, NULL, 10);
+ last_subid = strtoul_err(oid_subid, NULL, 10, &error);
+ if (error != 0) {
+ return WERR_INVALID_PARAMETER;
+ }
/* encode oid in BER format */
if (!ber_write_OID_String(mem_ctx, _bin_oid, full_oid)) {
case REG_DWORD:
case REG_DWORD_BIG_ENDIAN:
if (val != NULL) {
+ int error = 0;
/* The data is a plain DWORD */
- uint32_t tmp = strtoul((char *)val->data, NULL, 0);
+ uint32_t tmp;
+
+ tmp = strtoul_err((char *)val->data, NULL, 0, &error);
+ if (error != 0) {
+ data->data = NULL;
+ data->length = 0;
+ break;
+ }
data->data = talloc_size(mem_ctx, sizeof(uint32_t));
if (data->data != NULL) {
SIVAL(data->data, 0, tmp);
case REG_QWORD:
if (val != NULL) {
+ int error = 0;
/* The data is a plain QWORD */
- uint64_t tmp = strtoull((char *)val->data, NULL, 0);
+ uint64_t tmp;
+
+ tmp = strtoull_err((char *)val->data, NULL, 0, &error);
+ if (error != 0) {
+ data->data = NULL;
+ data->length = 0;
+ break;
+ }
data->data = talloc_size(mem_ctx, sizeof(uint64_t));
if (data->data != NULL) {
SBVAL(data->data, 0, tmp);
}
} else {
char *endp = NULL;
- unsigned long val = strtoul(p, &endp, 0);
- if (p == endp || (endp && *endp != '\0')) {
+ int error = 0;
+
+ unsigned long val = strtoul_err(p, &endp, 0, &error);
+ if (p == endp || (endp && *endp != '\0') || error != 0) {
DEBUG(2,("interpret_interface: "
"can't determine netmask value from %s\n",
p));
uint32_t port = 0;
char *p = strrchr(addrs[i], '@');
char *n;
+ int error = 0;
if (!p) {
composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND);
composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND);
return;
}
- port = strtoul(p, NULL, 10);
- if (port > UINT16_MAX) {
+ port = strtoul_err(p, NULL, 10, &error);
+ if (port > UINT16_MAX || error != 0) {
composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND);
return;
}
struct nbt_name *name;
unsigned int comp_num;
uint32_t cur = 0;
+ int error = 0;
name = talloc(mem_ctx, struct nbt_name);
if (!name) {
}
if (comp_num > cur && strcasecmp("type", ldb_dn_get_component_name(dn, cur)) == 0) {
- name->type = strtoul((char *)ldb_dn_get_component_val(dn, cur)->data, NULL, 0);
+ name->type =
+ strtoul_err(
+ (char *)ldb_dn_get_component_val(dn, cur)->data,
+ NULL,
+ 0,
+ &error);
+ if (error != 0) {
+ status = NT_STATUS_INTERNAL_DB_CORRUPTION;
+ goto failed;
+ }
cur++;
} else {
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
uint32_t orig_uint = 0;
unsigned int flags = 0;
int ret;
+ int error = 0;
orig_val = ldb_msg_find_ldb_val(orig, attribute);
if (!orig_val || !orig_val->data) {
flags = LDB_FLAG_MOD_ADD;
} else {
- errno = 0;
- orig_uint = strtoul((const char *)orig_val->data, NULL, 0);
- if (errno != 0 || orig_uint != value) {
+ orig_uint = strtoul_err((const char *)orig_val->data,
+ NULL,
+ 0,
+ &error);
+ if (error != 0 || orig_uint != value) {
/* replace also if can't get value */
flags = LDB_FLAG_MOD_REPLACE;
}
while (fgets(line, sizeof(line)-1, f)) {
NTSTATUS status;
const char **params0, **params;
+ unsigned long int tmp;
+ int error = 0;
nbench_line_count++;
/* accept numeric or string status codes */
if (strncmp(params[i-1], "0x", 2) == 0) {
- status = NT_STATUS(strtoul(params[i-1], NULL, 16));
+ tmp = strtoul_err(params[i-1], NULL, 16, &error);
+ if (error != 0) {
+ tmp = error;
+ }
+ status = NT_STATUS(tmp);
} else {
status = nt_status_string_to_code(params[i-1]);
}
struct smb2_create create = { };
NTSTATUS status;
bool ret = true;
+ int error = 0;
sharemode_string = torture_setting_string(tctx, "sharemode", "RWD");
sharemode = smb2_util_share_access(sharemode_string);
access_string = torture_setting_string(tctx, "access", "0xf01ff");
- access = strtoul(access_string, NULL, 0);
+ access = strtoul_err(access_string, NULL, 0, &error);
+ if (error != 0) {
+ torture_comment(tctx, "Initializing access failed.\n");
+ return false;
+ }
filename = torture_setting_string(tctx, "filename", "testfile");
operation = torture_setting_string(tctx, "operation", "WD");
*/
NTSTATUS http_parse_header(struct websrv_context *web, const char *line)
{
+ int error = 0;
+
if (line[0] == 0) {
web->input.end_of_headers = true;
} else if (strncasecmp(line,"GET ", 4)==0) {
http_error(web, "400 Bad request", "This server only accepts GET and POST requests");
return NT_STATUS_INVALID_PARAMETER;
} else if (strncasecmp(line, "Content-Length: ", 16)==0) {
- web->input.content_length = strtoul(&line[16], NULL, 10);
+ web->input.content_length = strtoul_err(&line[16], NULL, 10, &error);
+ if (error != 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
} else {
struct http_header *hdr = talloc_zero(web, struct http_header);
char *colon = strchr(line, ':');