diff options
author | Matthieu Patou <mat@matws.net> | 2010-09-04 20:08:05 +0400 |
---|---|---|
committer | Matthieu Patou <mat@matws.net> | 2010-10-05 11:19:40 +0400 |
commit | 83f3f5e15aa9928f998c3afe03e71a53ad8e8d6a (patch) | |
tree | 37ab19db3dce6fc91a4044a1773f5481e0e91aa9 | |
parent | 7c5d7a5b6337b8543ebb9c71e8d97eceb7a1e44e (diff) | |
download | samba-83f3f5e15aa9928f998c3afe03e71a53ad8e8d6a.tar.gz samba-83f3f5e15aa9928f998c3afe03e71a53ad8e8d6a.tar.bz2 samba-83f3f5e15aa9928f998c3afe03e71a53ad8e8d6a.zip |
ndr: Handle the case of string array with all null terminated strings
-rw-r--r-- | librpc/ndr/ndr_string.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c index 2e04633963..e1f3a5245a 100644 --- a/librpc/ndr/ndr_string.c +++ b/librpc/ndr/ndr_string.c @@ -456,7 +456,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string_array(struct ndr_pull *ndr, int ndr_f case LIBNDR_FLAG_STR_NULLTERM: /* * here the strings are null terminated - * but also the array is null terminated + * but also the array is null terminated if LIBNDR_FLAG_REMAINING + * is specified */ for (count = 0;; count++) { TALLOC_CTX *tmp_ctx; @@ -469,6 +470,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; @@ -491,11 +497,14 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string_array(struct ndr_pull *ndr, int ndr_f * but serarated by a null terminator * * which means the same as: - * very string is null terminated exept the last + * Every string is null terminated exept the last * string is terminated by the end of the buffer * * as LIBNDR_FLAG_STR_NULLTERM also end at the end * of the buffer, we can pull each string with this flag + * + * The big difference with the case LIBNDR_FLAG_STR_NOTERM + + * LIBNDR_FLAG_REMAINING is that the last string will not be null terminated */ ndr->flags &= ~(LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING); ndr->flags |= LIBNDR_FLAG_STR_NULLTERM; @@ -545,8 +554,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_string_array(struct ndr_push *ndr, int ndr_f for (count = 0; a && a[count]; count++) { NDR_CHECK(ndr_push_string(ndr, ndr_flags, a[count])); } - - NDR_CHECK(ndr_push_string(ndr, ndr_flags, "")); + /* If LIBNDR_FLAG_REMAINING then we do not add a null terminator to the array */ + if (!(flags & LIBNDR_FLAG_REMAINING)) + { + NDR_CHECK(ndr_push_string(ndr, ndr_flags, "")); + } break; case LIBNDR_FLAG_STR_NOTERM: |