From 291c5ed53c9957d1da981fa39477b046b94fe192 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 15 Sep 2006 17:34:46 +0000 Subject: r18559: [string] always applies to the last pointer (This used to be commit 86b4624226d6e72645221cadb8669b0f1aba0903) --- source4/pidl/lib/Parse/Pidl/NDR.pm | 3 ++- source4/pidl/tests/ndr_string.pl | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 114de797b8..f602bd2d68 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -204,7 +204,8 @@ sub GetElementLevelTable($) } } - if (scalar(@size_is) == 0 and has_property($e, "string")) { + if (scalar(@size_is) == 0 and has_property($e, "string") and + $i == $e->{POINTERS}) { $is_string = 1; $is_varying = $is_conformant = has_property($e, "noheader")?0:1; delete($e->{PROPERTIES}->{string}); diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index e8e37be8c1..00ccbb31bb 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 2 * 8; +use Test::More tests => 3 * 8; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use lib "$RealBin"; @@ -53,3 +53,32 @@ test_samba4_ndr("string-ascii-pull", if (r.in.data[4] != 0) return 4; '); + +test_samba4_ndr("string-out", +' + [public] void TestString([out,string] uint8 **data); +', +' + uint8_t data[] = { 0x03, 0x00, 0x00, 0x00, + \'f\', \'o\', \'o\', 0 }; + DATA_BLOB b = { data, 8 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct TestString r; + char *str = NULL; + r.out.data = &str; + + if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + return 1; + + if (r.out.data == NULL) + return 2; + + if (*r.out.data == NULL) + return 3; + + if (strncmp(r.out.data, "foo", 3) != 0) + return 3; + + if (r.in.data[4] != 0) + return 4; +'); -- cgit