security.idl: sometimes ACEs have some padding at the end
[kai/samba.git] / librpc / ndr / ndr_sec_helper.c
index 009e3524a71e0a7811f6afef18009973063af671..4b135505d883806337c2c3087aaa7d4c26ae406f 100644 (file)
@@ -55,6 +55,36 @@ size_t ndr_size_security_ace(const struct security_ace *ace, int flags)
        return ret;
 }
 
+enum ndr_err_code ndr_pull_security_ace(struct ndr_pull *ndr, int ndr_flags, struct security_ace *r)
+{
+       if (ndr_flags & NDR_SCALARS) {
+               uint32_t start_ofs = ndr->offset;
+               uint32_t size = 0;
+               uint32_t pad = 0;
+               NDR_CHECK(ndr_pull_align(ndr, 4));
+               NDR_CHECK(ndr_pull_security_ace_type(ndr, NDR_SCALARS, &r->type));
+               NDR_CHECK(ndr_pull_security_ace_flags(ndr, NDR_SCALARS, &r->flags));
+               NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size));
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->access_mask));
+               NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->object, r->type));
+               NDR_CHECK(ndr_pull_security_ace_object_ctr(ndr, NDR_SCALARS, &r->object));
+               NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, &r->trustee));
+               size = ndr->offset - start_ofs;
+               if (r->size < size) {
+                       return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
+                                             "ndr_pull_security_ace: r->size %u < size %u",
+                                             (unsigned)r->size, size);
+               }
+               pad = r->size - size;
+               NDR_PULL_NEED_BYTES(ndr, pad);
+               ndr->offset += pad;
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               NDR_CHECK(ndr_pull_security_ace_object_ctr(ndr, NDR_BUFFERS, &r->object));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
 /*
   return the wire size of a security_acl
 */