The branch, master has been updated via 846aa18... s3-spoolss: fixes for _spoolss_EnumPrinterKey client and server. via 2707dfb... s3-registry: use push_reg_multi_sz() in registry_push_value(). via d4e0659... s3-registry: remove reg_pull_multi_sz(). from be90385... s3:torture: use timeval_current/timeval_elapsed instead of start_timer/end_timer
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 846aa18648f3b34ab5cbc4dc4ba334bbedeab2f4 Author: Günther Deschner <g...@samba.org> Date: Tue Nov 24 15:22:04 2009 +0100 s3-spoolss: fixes for _spoolss_EnumPrinterKey client and server. Thanks Metze for review! Guenther commit 2707dfb441801e753c74657f20b5ca22a274778f Author: Günther Deschner <g...@samba.org> Date: Tue Nov 24 15:26:32 2009 +0100 s3-registry: use push_reg_multi_sz() in registry_push_value(). Guenther commit d4e06596d50e008425b9d346c3814a03eea8309a Author: Günther Deschner <g...@samba.org> Date: Tue Nov 24 15:26:08 2009 +0100 s3-registry: remove reg_pull_multi_sz(). Guenther ----------------------------------------------------------------------- Summary of changes: source3/include/proto.h | 2 - source3/lib/util_reg.c | 23 --------- source3/lib/util_reg_api.c | 85 +++++++++-------------------------- source3/rpc_client/cli_spoolss.c | 4 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- 5 files changed, 24 insertions(+), 92 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/proto.h b/source3/include/proto.h index 8951e73..6b68f95 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1261,8 +1261,6 @@ struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ; /* The following definitions come from lib/util_reg.c */ const char *reg_type_lookup(enum winreg_Type type); -WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len, - uint32 *num_values, char ***values); bool push_reg_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *s); bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a); bool pull_reg_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **s); diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c index ca46f86..850dbfa 100644 --- a/source3/lib/util_reg.c +++ b/source3/lib/util_reg.c @@ -73,29 +73,6 @@ const char *reg_type_lookup(enum winreg_Type type) return result; } -WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len, - uint32 *num_values, char ***values) -{ - DATA_BLOB blob; - const char **vals; - int i; - - blob = data_blob_const((uint8_t *)buf, len); - - if (!pull_reg_multi_sz(mem_ctx, &blob, &vals)) { - return WERR_NOMEM; - } - - for (i=0; vals[i]; i++) { - ;; - } - - *num_values = i; - *values = (char **)vals; - - return WERR_OK; -} - /******************************************************************* push a string in unix charset into a REG_SZ UCS2 null terminated blob ********************************************************************/ diff --git a/source3/lib/util_reg_api.c b/source3/lib/util_reg_api.c index 56ecc54..309fa62 100644 --- a/source3/lib/util_reg_api.c +++ b/source3/lib/util_reg_api.c @@ -102,14 +102,27 @@ WERROR registry_pull_value(TALLOC_CTX *mem_ctx, SAFE_FREE(tmp); break; } - case REG_MULTI_SZ: - err = reg_pull_multi_sz(value, (void *)data, length, - &value->v.multi_sz.num_strings, - &value->v.multi_sz.strings); - if (!(W_ERROR_IS_OK(err))) { + case REG_MULTI_SZ: { + int i; + const char **vals; + DATA_BLOB blob; + + blob = data_blob_const(data, length); + + if (!pull_reg_multi_sz(mem_ctx, &blob, &vals)) { + err = WERR_NOMEM; goto error; } + + for (i=0; vals[i]; i++) { + ;; + } + + value->v.multi_sz.num_strings = i; + value->v.multi_sz.strings = (char **)vals; + break; + } case REG_BINARY: value->v.binary = data_blob_talloc(mem_ctx, data, length); break; @@ -142,74 +155,18 @@ WERROR registry_push_value(TALLOC_CTX *mem_ctx, } case REG_SZ: case REG_EXPAND_SZ: { - if (!convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16LE, - value->v.sz.str, - MIN(value->v.sz.len, - strlen(value->v.sz.str)+1), - (void *)&(presult->data), - &presult->length, False)) + if (!push_reg_sz(mem_ctx, presult, value->v.sz.str)) { return WERR_NOMEM; } break; } - case REG_MULTI_SZ: { - uint32_t count; - size_t len = 0; - char **strings; - size_t *string_lengths; - uint32_t ofs; - TALLOC_CTX *tmp_ctx = talloc_stackframe(); - - strings = TALLOC_ARRAY(tmp_ctx, char *, - value->v.multi_sz.num_strings); - if (strings == NULL) { - return WERR_NOMEM; - } - - string_lengths = TALLOC_ARRAY(tmp_ctx, size_t, - value->v.multi_sz.num_strings); - if (string_lengths == NULL) { - TALLOC_FREE(tmp_ctx); - return WERR_NOMEM; - } - - /* convert the single strings */ - for (count = 0; count < value->v.multi_sz.num_strings; count++) + case REG_MULTI_SZ: + if (!push_reg_multi_sz(mem_ctx, presult, (const char **)value->v.multi_sz.strings)) { - if (!convert_string_talloc(strings, CH_UNIX, - CH_UTF16LE, value->v.multi_sz.strings[count], - strlen(value->v.multi_sz.strings[count])+1, - (void *)&strings[count], - &string_lengths[count], false)) - { - - TALLOC_FREE(tmp_ctx); - return WERR_NOMEM; - } - len += string_lengths[count]; - } - - /* now concatenate all into the data blob */ - presult->data = TALLOC_ARRAY(mem_ctx, uint8_t, len); - if (presult->data == NULL) { - TALLOC_FREE(tmp_ctx); return WERR_NOMEM; } - for (count = 0, ofs = 0; - count < value->v.multi_sz.num_strings; - count++) - { - memcpy(presult->data + ofs, strings[count], - string_lengths[count]); - ofs += string_lengths[count]; - } - presult->length = len; - - TALLOC_FREE(tmp_ctx); - break; - } case REG_BINARY: *presult = data_blob_talloc(mem_ctx, value->v.binary.data, diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 2dba103..6d6d5df 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -815,7 +815,7 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, *key_buffer = NULL; if (offered) { - buffer = talloc_array(mem_ctx, uint16_t, offered); + buffer = talloc_array(mem_ctx, uint16_t, offered/2); W_ERROR_HAVE_NO_MEMORY(buffer); } @@ -829,7 +829,7 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) { offered = needed; - buffer = talloc_realloc(mem_ctx, buffer, uint16_t, needed); + buffer = talloc_realloc(mem_ctx, buffer, uint16_t, needed/2); W_ERROR_HAVE_NO_MEMORY(buffer); status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx, handle, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 072090b..703dca1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9203,7 +9203,7 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p, goto done; } - if (r->in.offered == blob.length) { + if (r->in.offered >= blob.length) { memcpy(r->out.key_buffer, blob.data, blob.length); } -- Samba Shared Repository