[PATCH 2/3] s4: Fix problems for offset miscalculation and remove unelegant hack with offset miscalculation

Matthieu Patou mat at matws.net
Fri Nov 20 02:06:43 MST 2009


---
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm |    8 ++++----
 pidl/lib/Parse/Pidl/Samba4/Python.pm     |   18 +-----------------
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index fbdb827..d598989 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1054,12 +1054,12 @@ sub ParseElementPullLevel
 
 		if ($l->{POINTER_TYPE} ne "ref") {
 			if ($l->{POINTER_TYPE} eq "relative") {
-				$self->pidl("$ndr->offset = _relative_save_offset;");
-				$self->pidl("if ($ndr->offset > $ndr->relative_higest_offset) {");
+				$self->pidl("if ($ndr->offset > $ndr->relative_highest_offset) {");
 				$self->indent;
-				$self->pidl("$ndr->relative_higest_offset = $ndr->offset;");
-				$self->deident;
+				$self->pidl("$ndr->relative_highest_offset = $ndr->offset;");
+				$self->deindent;
 				$self->pidl("}");
+				$self->pidl("$ndr->offset = _relative_save_offset;");
 			}
 			$self->deindent;
 			$self->pidl("}");
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index c785619..41a8607 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -276,23 +276,7 @@ sub PythonStruct($$$$$$)
 		$self->pidl("\treturn NULL;");
 		$self->pidl("");
 
-		# This disgusting hack works around the fact that ndr_pull_struct_blob_all will always fail on structures with relative pointers.  
-                # So, map ndr_unpack to ndr_pull_struct_blob_all only if we don't have any relative pointers in this
-		my $got_relative = 0;
-		if ($#{$d->{ELEMENTS}} > -1) {
-		        foreach my $e (@{$d->{ELEMENTS}}) {
-			        my $l = $e->{LEVELS}[0];
-				if ($l->{TYPE} eq "POINTER" and ($l->{POINTER_TYPE} eq "relative")) {
-				        $got_relative = 1;
-					last;
-				}
-			}
-		}
-		if ($got_relative == 0) {
-		        $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
-		} else {
-		        $self->pidl("err = ndr_pull_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
-		}
+    $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
 		$self->pidl("if (err != NDR_ERR_SUCCESS) {");
 		$self->indent;
 		$self->pidl("PyErr_SetNdrError(err);");
-- 
1.6.3.3


--------------070401010903090405050806
Content-Type: text/x-patch;
 name="0003-NDR-update-PIDL-generated-files.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0003-NDR-update-PIDL-generated-files.patch"



More information about the samba-technical mailing list