summaryrefslogtreecommitdiff
path: root/source3/librpc
diff options
context:
space:
mode:
authorTim Prouty <tim.prouty@isilon.com>2008-04-29 14:36:24 -0700
committerVolker Lendecke <vl@samba.org>2008-05-20 22:40:13 +0200
commitfb37f156009611af0dd454a0fb0829a09cd638ac (patch)
treee97403a13dd39b7ef485d36c6c7856045e6e4bf3 /source3/librpc
parent6ed27edbcd3ba1893636a8072c8d7a621437daf7 (diff)
downloadsamba-fb37f156009611af0dd454a0fb0829a09cd638ac.tar.gz
samba-fb37f156009611af0dd454a0fb0829a09cd638ac.tar.bz2
samba-fb37f156009611af0dd454a0fb0829a09cd638ac.zip
Cleanup size_t return values in callers of convert_string_allocate
This patch is the second iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 6b189dabc562d86dcaa685419d0cb6ea276f100d)
Diffstat (limited to 'source3/librpc')
-rw-r--r--source3/librpc/ndr/ndr_string.c154
1 files changed, 74 insertions, 80 deletions
diff --git a/source3/librpc/ndr/ndr_string.c b/source3/librpc/ndr/ndr_string.c
index e553443bd8..1c0675849c 100644
--- a/source3/librpc/ndr/ndr_string.c
+++ b/source3/librpc/ndr/ndr_string.c
@@ -30,7 +30,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
char *as=NULL;
uint32_t len1, ofs, len2;
uint16_t len3;
- int ret;
+ size_t converted_size;
int chset = CH_UTF16;
unsigned byte_mul = 2;
unsigned flags = ndr->flags;
@@ -81,15 +81,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len2 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len2 + c_len_term)*byte_mul,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset,
+ CH_UNIX,
+ ndr->data+ndr->offset,
+ (len2 + c_len_term)*byte_mul,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul));
@@ -119,15 +119,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len1 + c_len_term)*byte_mul,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset,
+ CH_UNIX,
+ ndr->data+ndr->offset,
+ (len1 + c_len_term)*byte_mul,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul));
@@ -158,15 +158,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len1 + c_len_term)*byte_mul,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset,
+ CH_UNIX,
+ ndr->data+ndr->offset,
+ (len1 + c_len_term)*byte_mul,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul));
@@ -193,15 +193,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len3 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- (len3 + c_len_term)*byte_mul,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset,
+ CH_UNIX,
+ ndr->data+ndr->offset,
+ (len3 + c_len_term)*byte_mul,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul));
@@ -226,15 +226,14 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len3 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- len3,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset,
+ CH_UNIX,
+ ndr->data+ndr->offset, len3,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, len3));
@@ -247,15 +246,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
} else {
len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
}
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- len1,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
+ ndr->data+ndr->offset, len1,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
NDR_CHECK(ndr_pull_advance(ndr, len1));
*s = as;
@@ -265,15 +262,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
case LIBNDR_FLAG_STR_FIXLEN32:
len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
NDR_PULL_NEED_BYTES(ndr, len1*byte_mul);
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- len1*byte_mul,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
+ ndr->data+ndr->offset, len1*byte_mul,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul));
*s = as;
@@ -291,15 +286,14 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- len1,
- (void **)(void *)&as,
- false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset,
+ CH_UNIX,
+ ndr->data+ndr->offset, len1,
+ (void **)(void *)&as,
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, len1));
@@ -357,11 +351,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
LIBNDR_FLAG_STR_FIXLEN32))) {
s_len++;
}
- d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len,
- (void **)(void *)&dest, false);
- if (d_len == -1) {
+ if (!convert_string_talloc(ndr, CH_UNIX, chset, s, s_len,
+ (void **)(void *)&dest, &d_len, false))
+ {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
if (flags & LIBNDR_FLAG_STR_BYTESIZE) {
@@ -408,7 +402,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
uint32_t pad_len = fix_len - d_len;
if (d_len > fix_len) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
if (pad_len != 0) {
@@ -679,7 +673,8 @@ _PUBLIC_ enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uin
_PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset)
{
- int ret;
+ size_t converted_size;
+
if (length == 0) {
*var = talloc_strdup(ndr->current_mem_ctx, "");
return NDR_ERR_SUCCESS;
@@ -691,14 +686,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags,
NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
- ret = convert_string_talloc(ndr->current_mem_ctx,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- length*byte_mul,
- discard_const_p(void *, var), false);
- if (ret == -1) {
+ if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
+ ndr->data+ndr->offset, length*byte_mul,
+ discard_const_p(void *, var),
+ &converted_size, false))
+ {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
NDR_CHECK(ndr_pull_advance(ndr, length*byte_mul));
@@ -721,7 +715,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags,
ndr->data+ndr->offset, required, false);
if (ret == -1) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
+ "Bad char conversion");
}
/* Make sure the remaining part of the string is filled with zeroes */