lib: Make sid_parse return the parsed length
[samba.git] / source3 / lib / tldap_util.c
index 508c6c02f804518fd1bbfa505f2048cdacb16c71..efc37e48e7c52f44840a6b88d78388aeff2f8995 100644 (file)
@@ -88,11 +88,13 @@ bool tldap_pull_binsid(struct tldap_message *msg, const char *attribute,
                       struct dom_sid *sid)
 {
        DATA_BLOB val;
+       struct sid_parse_ret ret;
 
        if (!tldap_get_single_valueblob(msg, attribute, &val)) {
                return false;
        }
-       return sid_parse(val.data, val.length, sid);
+       ret = sid_parse(val.data, val.length, sid);
+       return (ret.len != -1);
 }
 
 bool tldap_pull_guid(struct tldap_message *msg, const char *attribute,
@@ -389,13 +391,22 @@ bool tldap_pull_uint64(struct tldap_message *msg, const char *attr,
 {
        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;
@@ -457,7 +468,6 @@ static void tldap_fetch_rootdse_done(struct tevent_req *subreq)
 
        rc = tldap_search_recv(subreq, state, &msg);
        if (tevent_req_ldap_error(req, rc)) {
-               TALLOC_FREE(subreq);
                return;
        }
 
@@ -739,7 +749,6 @@ static void tldap_search_paged_done(struct tevent_req *subreq)
 
        rc = tldap_search_recv(subreq, state, &state->result);
        if (tevent_req_ldap_error(req, rc)) {
-               TALLOC_FREE(subreq);
                return;
        }