{
unsigned long val;
char *endptr;
+ int error = 0;
- val = strtoul(str, &endptr, 10);
+ val = strtoul_err(str, &endptr, 10, &error);
if (str == endptr) {
return false;
if (*endptr != '\0') {
return false;
}
- if ((val == ULONG_MAX) && (errno == ERANGE)) {
- return false;
- }
- if ((val & UINT32_MAX) != val) {
- /* overflow */
+ if (error != 0) {
return false;
}
*result = val; /* Potential crop */
}
if (strequal(argv[2], "dword")) {
- uint32_t v = strtoul(argv[3], NULL, 10);
+ int error = 0;
+ uint32_t v;
+
+ v = strtoul_err(argv[3], NULL, 10, &error);
+ if (error != 0) {
+ goto done;
+ }
+
value.type = REG_DWORD;
value.data = data_blob_talloc(ctx, NULL, 4);
SIVAL(value.data.data, 0, v);
state.increment = 1;
if (argc == 3) {
- state.increment = strtoul(argv[2], NULL, 10);
+ int error = 0;
+
+ state.increment = strtoul_err(argv[2], NULL, 10, &error);
+ if (error != 0) {
+ goto done;
+ }
}
status = g_lock_do(string_term_tdb_data("registry_increment_lock"),
}
if (strequal(argv[2], "dword")) {
- uint32_t v = strtoul(argv[3], NULL, 10);
+ int error = 0;
+ uint32_t v;
+
+ v = strtoul_err(argv[3], NULL, 10, &error);
+ if (error != 0) {
+ goto error;
+ }
+
value.type = REG_DWORD;
value.data = data_blob_talloc(mem_ctx, NULL, 4);
SIVAL(value.data.data, 0, v);
uint32_t old_value = 0;
enum pdb_policy_type field;
char *endptr;
+ int err = 0;
if (argc != 2 || c->display_usage) {
d_fprintf(stderr, "%s\n%s",
value = -1;
}
else {
- value = strtoul(argv[1], &endptr, 10);
+ value = strtoul_err(argv[1], &endptr, 10, &err);
- if ((endptr == argv[1]) || (endptr[0] != '\0')) {
+ if ((endptr == argv[1]) || (endptr[0] != '\0') || (err != 0)) {
d_printf(_("Unable to set policy \"%s\"! Invalid value "
"\"%s\".\n"),
account_policy, argv[1]);
time_t value = get_time_t_max();
if (strcmp(kickoff_time, "never") != 0) {
- uint32_t num = strtoul(kickoff_time, &endptr, 10);
-
- if ((endptr == kickoff_time) || (endptr[0] != '\0')) {
+ int error = 0;
+ uint32_t num;
+
+ num = strtoul_err(kickoff_time, &endptr, 10, &error);
+ if ((endptr == kickoff_time) ||
+ (endptr[0] != '\0') ||
+ (error != 0))
+ {
fprintf(stderr, "Failed to parse kickoff time\n");
return -1;
}
bool rv;
const char *buf;
char *endp;
+ int error = 0;
struct dialog_section_text_field *text_field =
talloc_get_type_abort(section, struct dialog_section_text_field);
if (buf == NULL) {
return false;
}
- *out = strtoull(buf, &endp, 0);
+ *out = strtoull_err(buf, &endp, 0, &error);
rv = true;
- if (endp == buf || endp == NULL || endp[0] != '\0') {
+ if (endp == buf || endp == NULL || endp[0] != '\0' || error != 0) {
rv = false;
}