summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-10-01 23:29:53 +0200
committerMichael Adam <obnox@samba.org>2013-10-02 00:06:35 +0200
commitd2c892cd2e6b35898208296522ab83042a0ee28c (patch)
treefdb4d7f2562ac9b321c5b518fe0491a36fae4edb /source3/utils
parent063ec55e13d5ca09533cf2201b250769f7dbe27c (diff)
downloadsamba-d2c892cd2e6b35898208296522ab83042a0ee28c.tar.gz
samba-d2c892cd2e6b35898208296522ab83042a0ee28c.tar.bz2
samba-d2c892cd2e6b35898208296522ab83042a0ee28c.zip
net idmap: add utility function parse_uint32()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_idmap.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 55cde381ae..a6b8592ca0 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -622,6 +622,30 @@ done:
return ret;
}
+static bool parse_uint32(const char *str, uint32_t *result)
+{
+ unsigned long val;
+ char *endptr;
+
+ val = strtoul(str, &endptr, 10);
+
+ if (str == endptr) {
+ return false;
+ }
+ if (*endptr != '\0') {
+ return false;
+ }
+ if ((val == ULONG_MAX) && (errno == ERANGE)) {
+ return false;
+ }
+ if ((val & UINT32_MAX) != val) {
+ /* overflow */
+ return false;
+ }
+ *result = val; /* Potential crop */
+ return true;
+}
+
static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {