summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-08-30 13:34:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:35:02 -0500
commit172089214ed7bc30440f876262943cd5c2faafe7 (patch)
treea62a6fba7b808f6ec0f7cc4d5f18f9854f11fe78
parent89e550ba34d1f00b576aae3d4683ca9ca36afe80 (diff)
downloadsamba-172089214ed7bc30440f876262943cd5c2faafe7.tar.gz
samba-172089214ed7bc30440f876262943cd5c2faafe7.tar.bz2
samba-172089214ed7bc30440f876262943cd5c2faafe7.zip
r9795: fix the ndr_pull_string code to handle, some special cases,
where the idl was something like this: uint32 size; [size_is(size+1)] wchar_t *string; we always need a pair of NDR_PULL_NEEDED_BYTES() and ndr_pull_advance(), with the same size passed in. metze (This used to be commit 8eb75bd5ac5869f11f930ec872ec8a46fba9361b)
-rw-r--r--source4/librpc/ndr/ndr_string.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index e9d6425f54..a007f7c188 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -79,18 +79,18 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
"Bad string lengths len1=%u ofs=%u len2=%u\n",
len1, ofs, len2);
}
- if (len2 == 0) {
- *s = talloc_strdup(ndr, "");
- break;
- }
NDR_PULL_NEED_BYTES(ndr, (len2 + c_len_term)*byte_mul);
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len2 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ if (len2 == 0) {
+ as = talloc_strdup(ndr, "");
+ } else {
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ (len2 + c_len_term)*byte_mul,
+ (void **)&as);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
}
NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul));
@@ -125,16 +125,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1));
NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul);
if (len1 == 0) {
- *s = talloc_strdup(ndr, "");
- break;
- }
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len1 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ as = talloc_strdup(ndr, "");
+ } else {
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ (len1 + c_len_term)*byte_mul,
+ (void **)&as);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
}
NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul));
@@ -162,16 +162,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1));
NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul);
if (len1 == 0) {
- *s = talloc_strdup(ndr, "");
- break;
- }
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len1 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ as = talloc_strdup(ndr, "");
+ } else {
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ (len1 + c_len_term)*byte_mul,
+ (void **)&as);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
}
NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul));
@@ -195,16 +195,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3));
NDR_PULL_NEED_BYTES(ndr, (len3 + c_len_term)*byte_mul);
if (len3 == 0) {
- *s = talloc_strdup(ndr, "");
- break;
- }
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len3 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ as = talloc_strdup(ndr, "");
+ } else {
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ (len3 + c_len_term)*byte_mul,
+ (void **)&as);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
}
NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul));
@@ -226,16 +226,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3));
NDR_PULL_NEED_BYTES(ndr, len3);
if (len3 == 0) {
- *s = talloc_strdup(ndr, "");
- break;
- }
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
- ndr->data+ndr->offset,
- len3,
- (void **)&as);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ as = talloc_strdup(ndr, "");
+ } else {
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ len3,
+ (void **)&as);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
}
NDR_CHECK(ndr_pull_advance(ndr, len3));
*s = as;