diff options
author | Tim Prouty <tim.prouty@isilon.com> | 2008-04-29 14:36:24 -0700 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-05-20 22:40:13 +0200 |
commit | fb37f156009611af0dd454a0fb0829a09cd638ac (patch) | |
tree | e97403a13dd39b7ef485d36c6c7856045e6e4bf3 /source3/libgpo | |
parent | 6ed27edbcd3ba1893636a8072c8d7a621437daf7 (diff) | |
download | samba-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/libgpo')
-rw-r--r-- | source3/libgpo/gpext/registry.c | 23 | ||||
-rw-r--r-- | source3/libgpo/gpo_ini.c | 12 |
2 files changed, 22 insertions, 13 deletions
diff --git a/source3/libgpo/gpext/registry.c b/source3/libgpo/gpext/registry.c index 6cad8c796c..188a48ab49 100644 --- a/source3/libgpo/gpext/registry.c +++ b/source3/libgpo/gpext/registry.c @@ -258,6 +258,7 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx, char *key = NULL; char *value = NULL; enum gp_reg_action action = GP_REG_ACTION_NONE; + size_t converted_size; ZERO_STRUCTP(*reg_entry); @@ -268,12 +269,16 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx, if (strlen_w((const smb_ucs2_t *)file_entry->key.buffer) <= 0) return false; - if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer)) + if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer, + &converted_size)) + { return false; + } - if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0) { - if (!pull_ucs2_talloc(mem_ctx, &value, - file_entry->value.buffer)) + if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0 && + !pull_ucs2_talloc(mem_ctx, &value, file_entry->value.buffer, + &converted_size)) + { return false; } @@ -294,9 +299,13 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx, case REG_NONE: break; case REG_SZ: - data->v.sz.len = pull_ucs2_talloc(mem_ctx, - &data->v.sz.str, - (const smb_ucs2_t *)file_entry->data); + if (!pull_ucs2_talloc(mem_ctx, &data->v.sz.str, + (const smb_ucs2_t *) + file_entry->data, + &data->v.sz.len)) { + data->v.sz.len = -1; + } + break; case REG_DWORD_BIG_ENDIAN: case REG_EXPAND_SZ: diff --git a/source3/libgpo/gpo_ini.c b/source3/libgpo/gpo_ini.c index 6f1593c2c2..54aaffa477 100644 --- a/source3/libgpo/gpo_ini.c +++ b/source3/libgpo/gpo_ini.c @@ -57,6 +57,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx, char *tmp_name = NULL; NTSTATUS status; size_t n = 0; + size_t converted_size; if (!filename_out) { return NT_STATUS_INVALID_PARAMETER; @@ -81,10 +82,9 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx, goto out; } - n = convert_string_talloc(mem_ctx, CH_UTF16LE, CH_UNIX, - data_in, n, &data_out, False); - - if (n == -1) { + if (!convert_string_talloc(mem_ctx, CH_UTF16LE, CH_UNIX, data_in, n, + &data_out, &converted_size, False)) + { status = NT_STATUS_INVALID_BUFFER_SIZE; goto out; } @@ -99,10 +99,10 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx, DEBUG(11,("convert_file_from_ucs2: " "%s skipping utf8 BOM\n", tmp_name)); data_out += 3; - n -= 3; + converted_size -= 3; } - if (sys_write(tmp_fd, data_out, n) != n) { + if (sys_write(tmp_fd, data_out, converted_size) != converted_size) { status = map_nt_error_from_unix(errno); goto out; } |