adding one more case to ndr_pull_string_array/ndr_push_string_array

Jelmer Vernooij jelmer at vernstok.nl
Sat Sep 4 12:42:11 MDT 2010


On Sat, 2010-09-04 at 19:54 +0400, Matthieu Patou wrote:
> 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;
Do we already generate correct data from the push function ? The
ndr_push/ndr_pull functions should be consistent in how they handle
flags.

Cheers,

Jelmer


More information about the samba-technical mailing list