#include "lib/util/util_net.h"
#include "lib/util/samba_util.h"
#include "lib/async_req/async_sock.h"
+#include "lib/util/smb_strtox.h"
static int tsocket_bsd_error_from_errno(int ret,
int sys_errno,
int ret;
char *s_addr = NULL;
uint16_t s_port = default_port;
- bool conv_ret;
+ int error = 0;
bool is_ipv6_by_squares = false;
if (host_port_addr == NULL) {
return -1;
}
cport = port_sep + 1;
- conv_ret = conv_str_u64(cport, &port);
- if (!conv_ret) {
+ port = smb_strtoull(
+ cport, NULL, 10, &error, SMB_STR_FULL_STR_CONV);
+ if (error != 0) {
errno = EINVAL;
return -1;
}
} else if (pl_period != NULL && port_sep != NULL) {
/* IPv4 with port - more than one period in string */
cport = port_sep + 1;
- conv_ret = conv_str_u64(cport, &port);
- if (!conv_ret) {
+ port = smb_strtoull(
+ cport, NULL, 10, &error, SMB_STR_FULL_STR_CONV);
+ if (error != 0) {
errno = EINVAL;
return -1;
}
**/
_PUBLIC_ bool conv_str_size_error(const char * str, uint64_t * val);
-/**
- * Parse a uint64_t value from a string
- *
- * val will be set to the value read.
- *
- * @retval true if parsing was successful, false otherwise
- */
-_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val);
-
/**
* @brief Constant time compare to memory regions.
*
return true;
}
-/**
- * Parse a uint64_t value from a string
- *
- * val will be set to the value read.
- *
- * @retval true if parsing was successful, false otherwise
- */
-_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val)
-{
- unsigned long long lval;
- int error = 0;
-
- if (str == NULL || *str == '\0') {
- return false;
- }
-
- lval = smb_strtoull(str, NULL, 10, &error, SMB_STR_FULL_STR_CONV);
- if (error != 0) {
- return false;
- }
-
- *val = (uint64_t)lval;
- return true;
-}
-
/**
* Compare 2 strings.
*
#include "lib/adouble.h"
#include "lib/util_macstreams.h"
#include "source3/smbd/dir.h"
+#include "lib/util/smb_strtox.h"
/*
* Enhanced OS X and Netatalk compatibility
static regex_t re;
static bool re_initialized = false;
regmatch_t matches[2];
- uint64_t band_size;
int ret;
- bool ok;
+ int error = 0;
if (!re_initialized) {
ret = regcomp(&re,
line[matches[1].rm_eo] = '\0';
- ok = conv_str_u64(&line[matches[1].rm_so], &band_size);
- if (!ok) {
- return false;
- }
- *_band_size = (size_t)band_size;
- return true;
+ *_band_size = smb_strtoull(&line[matches[1].rm_so],
+ NULL,
+ 10,
+ &error,
+ SMB_STR_FULL_STR_CONV);
+ return (error == 0);
}
/*
#include "../rpc_server/mdssvc/mdssvc.h"
#include "../rpc_server/mdssvc/dalloc.h"
#include "../rpc_server/mdssvc/marshalling.h"
+#include "lib/util/smb_strtox.h"
static NTSTATUS cmd_mdssvc_fetch_properties(
struct rpc_pipe_client *cli,
uint64_t cnid;
uint32_t unkn4;
int result;
+ int error = 0;
bool ok;
if (argc != 4) {
return NT_STATUS_OK;
}
- ok = conv_str_u64(argv[3], &cnid);
- if (!ok) {
+ cnid = smb_strtoull(argv[3], NULL, 10, &error, SMB_STR_FULL_STR_CONV);
+ if (error != 0) {
printf("Failed to parse: %s\n", argv[3]);
return NT_STATUS_INVALID_PARAMETER;
}
#include "libcli/resolve/resolve.h"
#include "libcli/raw/libcliraw.h"
#include "lib/events/events.h"
+#include "lib/util/smb_strtox.h"
#include "cifsdd.h"
#include "param/param.h"
/* Found a matching name; convert the variable argument. */
switch (arg->arg_type) {
- case ARG_NUMERIC:
- if (!conv_str_u64(val, &arg->arg_val.nval)) {
- goto fail;
- }
- break;
+ case ARG_NUMERIC: {
+ int error = 0;
+ arg->arg_val.nval = smb_strtoull(
+ val, NULL, 10, &error, SMB_STR_FULL_STR_CONV);
+ if (error != 0) {
+ goto fail;
+ }
+ break;
+ }
case ARG_SIZE:
if (!conv_str_size_error(val, &arg->arg_val.nval)) {
goto fail;