From 3c31fe7600145662f8bdba98c8f13cbaac58685e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2013 17:45:02 +0100 Subject: s4-torture: make sure to deal with the highest relative pointer offset correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guenther Signed-off-by: Günther Deschner Reviewed-by: Stefan Metzmacher --- source4/torture/ndr/ndr.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'source4/torture/ndr/ndr.c') diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c index 30cd46ac58..9e63ff71d7 100644 --- a/source4/torture/ndr/ndr.c +++ b/source4/torture/ndr/ndr.c @@ -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); -- cgit