adding one more case to ndr_pull_string_array/ndr_push_string_array

Matthieu Patou mat at samba.org
Sat Sep 4 09:54:31 MDT 2010


  Dear all,

It seems that I have a small pb with dfs

The expanded names is an array of null terminated utf-16 strings but 
it's not null terminated that I declared like this:

      [relative_short,subcontext(0),flag(STR_NOTERM|NDR_REMAINING)] 
string *expanded_names

Although with this I'm able to parse message made from windows it causes 
a pb when s4 should act as a server for windows clients as the last 
expanded_names is not null terminated.

If I set the time to be nstring then w7 is happy but I'm not able to 
parse the expoted bytes that I attached.

I tried to use array to take advantage of the fact that I have the size 
with things like:


[relative_short] nstring tab[size]
or
[relative_short, size_is(size)] nstring *tab
or
[relative_short, size_is(size)] nstring tab[]

But either it didn't compile, or it didn't pass the test of ndrdump with 
the attached file.



I propose to add a kind of exception like:

diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c
index 2e04633..8de2257 100644
--- a/librpc/ndr/ndr_string.c
+++ b/librpc/ndr/ndr_string.c
@@ -469,6 +469,11 @@ _PUBLIC_ enum ndr_err_code 
ndr_pull_string_array(struct ndr_pull *ndr, int ndr_f
                         tmp_ctx = ndr->current_mem_ctx;
                         ndr->current_mem_ctx = a;
                         NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
+                       if ((ndr->data_size - ndr->offset) == 0 && 
ndr->flags & LIBNDR_FLAG_REMAINING)
+                       {
+                               a[count] = s;
+                               break;
+                       }
                         ndr->current_mem_ctx = tmp_ctx;
                         if (strcmp("", s)==0) {
                                 a[count] = NULL;

So that we can handle string_array of null terminated strings but 
without array terminator.

Let me know.

Matthieu.

-- 
Matthieu Patou
Samba Team        http://samba.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dfsblobs.idl
Type: text/x-idl
Size: 3127 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20100904/13e64432/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dfs_step2_w2k3
Type: image/x-icon
Size: 112 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20100904/13e64432/attachment.ico>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: result_dump
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20100904/13e64432/attachment.ksh>


More information about the samba-technical mailing list