[PATCH 1/3] hack _all with relative pointers
Stefan Metzmacher
metze at samba.org
Wed Nov 18 13:27:30 MST 2009
hack _all with relative pointers
---
librpc/ndr/libndr.h | 1 +
librpc/ndr/ndr.c | 10 ++++++++--
pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 7 ++++++-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 45cb244..e881a5c 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -62,6 +62,7 @@ struct ndr_pull {
struct smb_iconv_convenience *iconv_convenience;
+ uint32_t relative_highest_offset;
uint32_t relative_base_offset;
struct ndr_token_list *relative_base_list;
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index cb47ca1..7781331 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -861,13 +861,19 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
void *p, ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
+ uint32_t highest_ofs;
ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
- if (ndr->offset < ndr->data_size) {
+ if (ndr->offset > ndr->relative_highest_offset) {
+ highest_ofs = ndr->offset;
+ } else {
+ highest_ofs = ndr->relative_highest_offset;
+ }
+ if (highest_ofs < ndr->data_size) {
return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
"not all bytes consumed ofs[%u] size[%u]",
- ndr->offset, ndr->data_size);
+ highest_ofs, ndr->data_size);
}
talloc_free(ndr);
return NDR_ERR_SUCCESS;
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 11a43b4..fbdb827 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1053,8 +1053,13 @@ sub ParseElementPullLevel
$self->ParseMemCtxPullEnd($e, $l, $ndr);
if ($l->{POINTER_TYPE} ne "ref") {
- if ($l->{POINTER_TYPE} eq "relative") {
+ if ($l->{POINTER_TYPE} eq "relative") {
$self->pidl("$ndr->offset = _relative_save_offset;");
+ $self->pidl("if ($ndr->offset > $ndr->relative_higest_offset) {");
+ $self->indent;
+ $self->pidl("$ndr->relative_higest_offset = $ndr->offset;");
+ $self->deident;
+ $self->pidl("}");
}
$self->deindent;
$self->pidl("}");
--
1.6.3.3
--------------070401010903090405050806--
More information about the samba-technical
mailing list