librpc/ndr: handle NOALIGN flag for relative pointers and alignment DATA_BLOBs
authorStefan Metzmacher <metze@samba.org>
Tue, 1 Mar 2011 13:20:32 +0000 (14:20 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:56 +0000 (14:34 +0100)
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Tue Mar  1 17:11:03 CET 2011 on sn-devel-104
(cherry picked from commit ef224aa004d5f1726d8dca020e0ef96d8c58565e)
(cherry picked from commit 1ea17bacdb09d28a12a8b6ddeba3ac285cd9f905)

Signed-off-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 7c6bc031b3af3643027865e444fb16f7bb7c7152)

librpc/ndr/ndr.c
librpc/ndr/ndr_basic.c

index 9f2042d2401c83738ec29e27f485e3b3b144d2c1..2439374f7276860f27b6320e2d4f3ebd11a3a207 100644 (file)
@@ -1117,7 +1117,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, co
 
                relative_offset = ndr->offset - ndr->relative_base_offset;
 
-               if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
+               if (ndr->flags & LIBNDR_FLAG_NOALIGN) {
+                       align = 1;
+               } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                        align = 2;
                } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
                        align = 4;
@@ -1196,7 +1198,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_end(struct ndr_push *ndr, cons
        /* the reversed offset is at the end of the main buffer */
        correct_offset = ndr->relative_end_offset - len;
 
-       if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
+       if (ndr->flags & LIBNDR_FLAG_NOALIGN) {
+               align = 1;
+       } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                align = 2;
        } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
                align = 4;
index f913eff4ade80223addbe73276d1b450fa90b9d5..64ea6d77e9e803bf48b9cb4cbd454d8d65f765e1 100644 (file)
@@ -1012,8 +1012,11 @@ _PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_
 _PUBLIC_ enum ndr_err_code ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob)
 {
        if (ndr->flags & LIBNDR_FLAG_REMAINING) {
+               /* nothing to do */
        } else if (ndr->flags & LIBNDR_ALIGN_FLAGS) {
-               if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
+               if (ndr->flags & LIBNDR_FLAG_NOALIGN) {
+                       blob.length = 0;
+               } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                        blob.length = NDR_ALIGN(ndr, 2);
                } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
                        blob.length = NDR_ALIGN(ndr, 4);
@@ -1022,7 +1025,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flag
                }
                NDR_PUSH_ALLOC_SIZE(ndr, blob.data, blob.length);
                data_blob_clear(&blob);
-       } else if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) {
+       } else {
                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length));
        }
        NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length));
@@ -1039,7 +1042,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flag
        if (ndr->flags & LIBNDR_FLAG_REMAINING) {
                length = ndr->data_size - ndr->offset;
        } else if (ndr->flags & LIBNDR_ALIGN_FLAGS) {
-               if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
+               if (ndr->flags & LIBNDR_FLAG_NOALIGN) {
+                       length = 0;
+               } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                        length = NDR_ALIGN(ndr, 2);
                } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
                        length = NDR_ALIGN(ndr, 4);