diff options
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/NDR.pm | 3 | ||||
-rwxr-xr-x | 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; +'); |