librpc/ndr: let ndr_push/pull_DATA_BLOB() look at LIBNDR_FLAG_REMAINING before LIBNDR...
authorStefan Metzmacher <metze@samba.org>
Tue, 22 Feb 2011 17:19:13 +0000 (18:19 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:55 +0000 (14:34 +0100)
metze
(cherry picked from commit 6c3a49ced333988b21d86e47b2b1dd1a5957e15c)
(cherry picked from commit 5f8b7f95e9ce5946f048b242dbbaa14897aea919)

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

librpc/ndr/ndr_basic.c

index 50a89223089a8e71c45d421bb912477a826676c9..f913eff4ade80223addbe73276d1b450fa90b9d5 100644 (file)
@@ -1011,7 +1011,8 @@ _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_ALIGN_FLAGS) {
+       if (ndr->flags & LIBNDR_FLAG_REMAINING) {
+       } else if (ndr->flags & LIBNDR_ALIGN_FLAGS) {
                if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                        blob.length = NDR_ALIGN(ndr, 2);
                } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
@@ -1035,7 +1036,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flag
 {
        uint32_t length = 0;
 
-       if (ndr->flags & LIBNDR_ALIGN_FLAGS) {
+       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) {
                        length = NDR_ALIGN(ndr, 2);
                } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
@@ -1046,8 +1049,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flag
                if (ndr->data_size - ndr->offset < length) {
                        length = ndr->data_size - ndr->offset;
                }
-       } else if (ndr->flags & LIBNDR_FLAG_REMAINING) {
-               length = ndr->data_size - ndr->offset;
        } else {
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length));
        }