s4-torture: make sure to deal with the highest relative pointer offset correctly.
authorGünther Deschner <gd@samba.org>
Fri, 1 Feb 2013 16:45:02 +0000 (17:45 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 1 Feb 2013 18:38:07 +0000 (19:38 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/torture/ndr/ndr.c

index 30cd46ac58c713dab9b0d18718481673f023d6af..9e63ff71d7c57725cd4649dc2a88cfacdae37928 100644 (file)
@@ -43,6 +43,7 @@ static bool wrap_ndr_pullpush_test(struct torture_context *tctx,
        struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx);
        void *ds = talloc_zero_size(ndr, data->struct_size);
        bool ret;
+       uint32_t highest_ofs;
 
        ndr->flags |= data->flags;
 
@@ -51,9 +52,15 @@ static bool wrap_ndr_pullpush_test(struct torture_context *tctx,
        torture_assert_ndr_success(tctx, data->pull_fn(ndr, data->ndr_flags, ds),
                                   "pulling");
 
-       torture_assert(tctx, ndr->offset == ndr->data_size,
+       if (ndr->offset > ndr->relative_highest_offset) {
+               highest_ofs = ndr->offset;
+       } else {
+               highest_ofs = ndr->relative_highest_offset;
+       }
+
+       torture_assert(tctx, highest_ofs == ndr->data_size,
                                   talloc_asprintf(tctx,
-                                          "%d unread bytes", ndr->data_size - ndr->offset));
+                                          "%d unread bytes", ndr->data_size - highest_ofs));
 
        if (check_fn != NULL) {
                ret = check_fn(tctx, ds);
@@ -120,6 +127,7 @@ static bool wrap_ndr_inout_pull_test(struct torture_context *tctx,
        const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data;
        void *ds = talloc_zero_size(tctx, data->struct_size);
        struct ndr_pull *ndr;
+       uint32_t highest_ofs;
 
        /* handle NDR_IN context */
 
@@ -132,8 +140,14 @@ static bool wrap_ndr_inout_pull_test(struct torture_context *tctx,
                data->pull_fn(ndr, NDR_IN, ds),
                "ndr pull of context failed");
 
-       torture_assert(tctx, ndr->offset == ndr->data_size,
-               talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - ndr->offset));
+       if (ndr->offset > ndr->relative_highest_offset) {
+               highest_ofs = ndr->offset;
+       } else {
+               highest_ofs = ndr->relative_highest_offset;
+       }
+
+       torture_assert(tctx, highest_ofs == ndr->data_size,
+               talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs));
 
        talloc_free(ndr);
 
@@ -148,8 +162,14 @@ static bool wrap_ndr_inout_pull_test(struct torture_context *tctx,
                data->pull_fn(ndr, NDR_OUT, ds),
                "ndr pull failed");
 
-       torture_assert(tctx, ndr->offset == ndr->data_size,
-               talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - ndr->offset));
+       if (ndr->offset > ndr->relative_highest_offset) {
+               highest_ofs = ndr->offset;
+       } else {
+               highest_ofs = ndr->relative_highest_offset;
+       }
+
+       torture_assert(tctx, highest_ofs == ndr->data_size,
+               talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs));
 
        talloc_free(ndr);