while (key != NULL && *key != '\0') {
char *next_key;
char *val;
+ int error = 0;
next_key = strchr_m(key, ',');
if (next_key != NULL) {
*val++ = 0;
if (strequal_m(key, "speed")) {
- *speed = (uint64_t)strtoull(val, NULL, 0);
+ *speed = (uint64_t)strtoull_err(val, NULL, 0, &error);
+ if (error != 0) {
+ DBG_DEBUG("Invalid speed value (%s)\n", val);
+ }
} else if (strequal_m(key, "capability")) {
if (strequal_m(val, "RSS")) {
*cap |= FSCTL_NET_IFACE_RSS_CAPABLE;
"'%s'\n", val);
}
} else if (strequal_m(key, "if_index")) {
- *if_index = (uint32_t)strtoul(val, NULL, 0);
+ *if_index = (uint32_t)strtoul_err(val, NULL, 0, &error);
+ if (error != 0) {
+ DBG_DEBUG("Invalid key value (%s)\n", val);
+ }
} else {
DBG_DEBUG("Key unknown: '%s'\n", key);
}
return;
}
} else {
+ int error = 0;
char *endp = NULL;
- unsigned long val = strtoul(p, &endp, 0);
- if (p == endp || (endp && *endp != '\0')) {
+ unsigned long val;
+
+ 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));
*/
#include "replace.h"
+#include "util/util.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/dir.h"
{
char buf[25];
ssize_t rw_ret;
+ int error = 0;
unsigned long long unique;
char *endptr;
}
buf[rw_ret] = '\0';
- unique = strtoull(buf, &endptr, 10);
+ unique = strtoull_err(buf, &endptr, 10, &error);
if ((unique == 0) && (errno == EINVAL)) {
return EINVAL;
}
- if ((unique == ULLONG_MAX) && (errno == ERANGE)) {
- return ERANGE;
+
+ if (error != 0) {
+ return error;
}
+
if (endptr[0] != '\n') {
return EINVAL;
}
struct messaging_dgm_context *ctx = global_dgm_context;
DIR *msgdir;
struct dirent *dp;
+ int error = 0;
if (ctx == NULL) {
return ENOTCONN;
unsigned long pid;
int ret;
- pid = strtoul(dp->d_name, NULL, 10);
- if (pid == 0) {
+ pid = strtoul_err(dp->d_name, NULL, 10, &error);
+ if ((pid == 0) || (error != 0)) {
/*
* . and .. and other malformed entries
*/
#include "source3/lib/gencache.h"
#include "lib/util/debug.h"
#include "lib/util/strv.h"
+#include "lib/util/util.h"
#include "lib/util/talloc_stack.h"
#include "lib/util/charset/charset.h"
#include "libcli/security/dom_sid.h"
const char *domain;
const char *name;
const char *typebuf;
+ int error = 0;
char *endptr;
unsigned long type;
return;
}
- type = strtoul(typebuf, &endptr, 10);
- if (*endptr != '\0') {
- return;
- }
- if ((type == ULONG_MAX) && (errno == ERANGE)) {
+ type = strtoul_err(typebuf, &endptr, 10, &error);
+ if ((*endptr != '\0') || (error != 0)) {
return;
}
const char *sid_endptr;
const char *typebuf;
char *endptr;
+ int error = 0;
struct dom_sid sid;
unsigned long type;
bool ok;
return;
}
- type = strtoul(typebuf, &endptr, 10);
- if (*endptr != '\0') {
- return;
- }
- if ((type == ULONG_MAX) && (errno == ERANGE)) {
+ type = strtoul_err(typebuf, &endptr, 10, &error);
+ if ((*endptr != '\0') || (error != 0)) {
return;
}
char *p2;
char *syscmd = NULL;
int _id = -1;
+ int error = 0;
switch(qtype) {
case SMB_USER_QUOTA_TYPE:
/* we need to deal with long long unsigned here, if supported */
- dp->qflags = strtoul(line, &p2, 10);
+ dp->qflags = strtoul_err(line, &p2, 10, &error);
+ if (error != 0) {
+ goto invalid_param;
+ }
+
p = p2;
while (p && *p && isspace(*p)) {
p++;
{
char *str;
uint64_t result;
+ int error = 0;
str = tldap_talloc_single_attribute(msg, attr, talloc_tos());
if (str == NULL) {
DEBUG(10, ("Could not find attribute %s\n", attr));
return false;
}
- result = strtoull(str, NULL, 10);
+
+ result = strtoull_err(str, NULL, 10, &error);
+ if (error != 0) {
+ DBG_DEBUG("Attribute conversion failed (%s)\n",
+ strerror(error));
+ TALLOC_FREE(str);
+ return false;
+ }
+
TALLOC_FREE(str);
*presult = result;
return true;
{
uint64_t lval;
char * end;
+ int error = 0;
if (str == NULL || *str == '\0') {
return 0;
}
- lval = strtoull(str, &end, 10 /* base */);
+ lval = strtoull_err(str, &end, 10, &error);
- if (end == NULL || end == str) {
+ if (end == NULL || end == str || error != 0) {
return 0;
}
PTHREADPOOL
msghdr
genrand
+ samba-util
''',
private_library=True)
bld.RECURSE('rpcclient')
bld.RECURSE('utils')
bld.RECURSE('nmbd')
+bld.RECURSE('lib/util')
bld.ENFORCE_GROUP_ORDERING()
bld.CHECK_PROJECT_RULES()