diff options
Diffstat (limited to 'source4')
25 files changed, 168 insertions, 187 deletions
diff --git a/source4/auth/ntlm/ntlm_check.c b/source4/auth/ntlm/ntlm_check.c index 5298432e61..0805b1b043 100644 --- a/source4/auth/ntlm/ntlm_check.c +++ b/source4/auth/ntlm/ntlm_check.c @@ -323,7 +323,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx, if (lm_response->length && (convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, lm_response->data, lm_response->length, - (void **)&unix_pw, false) != -1)) { + (void **)&unix_pw, NULL, false))) { if (E_deshash(unix_pw, client_lm.hash)) { lm_ok = true; } else { diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c index d606b8d563..969845d6c5 100644 --- a/source4/auth/ntlmssp/ntlmssp_parse.c +++ b/source4/auth/ntlmssp/ntlmssp_parse.c @@ -44,14 +44,15 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *format, ...) { - int i; - ssize_t n; + int i, j; + bool ret; va_list ap; char *s; uint8_t *b; int head_size=0, data_size=0; int head_ofs, data_ofs; int *intargs; + size_t n; DATA_BLOB *pointers; @@ -65,8 +66,9 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, case 'U': s = va_arg(ap, char *); head_size += 8; - n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s); - if (n == -1) { + ret = push_ucs2_talloc(pointers, (smb_ucs2_t **)&pointers[i].data, + s, &n); + if (!ret) { return false; } pointers[i].length = n; @@ -76,8 +78,9 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, case 'A': s = va_arg(ap, char *); head_size += 8; - n = push_ascii_talloc(pointers, (char **)&pointers[i].data, s); - if (n == -1) { + ret = push_ascii_talloc(pointers, (char **)&pointers[i].data, s, + &n); + if (!ret) { return false; } pointers[i].length = n; @@ -85,11 +88,12 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, data_size += pointers[i].length; break; case 'a': - n = va_arg(ap, int); - intargs[i] = n; + j = va_arg(ap, int); + intargs[i] = j; s = va_arg(ap, char *); - n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s); - if (n == -1) { + ret = push_ucs2_talloc(pointers, (smb_ucs2_t **)&pointers[i].data, + s, &n); + if (!ret) { return false; } pointers[i].length = n; @@ -110,8 +114,8 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, head_size += pointers[i].length; break; case 'd': - n = va_arg(ap, int); - intargs[i] = n; + j = va_arg(ap, int); + intargs[i] = j; head_size += 4; break; case 'C': @@ -145,8 +149,8 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, data_ofs += n; break; case 'a': - n = intargs[i]; - SSVAL(blob->data, data_ofs, n); data_ofs += 2; + j = intargs[i]; + SSVAL(blob->data, data_ofs, j); data_ofs += 2; n = pointers[i].length; SSVAL(blob->data, data_ofs, n); data_ofs += 2; @@ -156,8 +160,8 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, data_ofs += n; break; case 'd': - n = intargs[i]; - SIVAL(blob->data, head_ofs, n); + j = intargs[i]; + SIVAL(blob->data, head_ofs, j); head_ofs += 4; break; case 'b': diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 82f5b6ed1d..19eb3433a9 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -1693,7 +1693,7 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ctx, "loadparm")), CH_UTF16, CH_UNIX, new_password->data, new_password->length, - (void **)&new_pass, false) != -1) { + (void **)&new_pass, NULL, false)) { /* possibly check password complexity */ diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index f427e697b4..56d4c4fe36 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -1307,7 +1307,7 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct ldb_context *ldb; bool ok; int ret; - ssize_t converted_pw_len; + size_t converted_pw_len; ldb = ldb_module_get_ctx(io->ac->module); @@ -1337,10 +1337,9 @@ static int setup_password_fields(struct setup_password_fields_io *io) ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), + if (!convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF8, CH_UTF16, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, - (void **)&cleartext_utf16_str, false); - if (converted_pw_len == -1) { + (void **)&cleartext_utf16_str, &converted_pw_len, false)) { ldb_asprintf_errstring(ldb, "setup_password_fields: " "failed to generate UTF16 password from cleartext UTF8 password"); @@ -1355,10 +1354,9 @@ static int setup_password_fields(struct setup_password_fields_io *io) ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), + if (!convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF16MUNGED, CH_UTF8, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length, - (void **)&cleartext_utf8_str, false); - if (converted_pw_len == -1) { + (void **)&cleartext_utf8_str, &converted_pw_len, false)) { /* We can't bail out entirely, as these unconvertable passwords are frustratingly valid */ io->n.cleartext_utf8 = NULL; talloc_free(cleartext_utf8_blob); @@ -1381,10 +1379,9 @@ static int setup_password_fields(struct setup_password_fields_io *io) if (io->n.cleartext_utf8) { struct samr_Password *lm_hash; char *cleartext_unix; - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), + if (convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF8, CH_UNIX, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, - (void **)&cleartext_unix, false); - if (converted_pw_len != -1) { + (void **)&cleartext_unix, &converted_pw_len, false)) { lm_hash = talloc(io->ac, struct samr_Password); if (!lm_hash) { ldb_oom(ldb); diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 0e8ac5e105..fbd8946bb5 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -1186,12 +1186,11 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb return WERR_INVALID_PARAM; \ } \ if (_a && _a->value_ctr.num_values >= 1) { \ - ssize_t _ret; \ - _ret = convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \ + size_t _ret; \ + if (!convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \ _a->value_ctr.values[0].blob->data, \ _a->value_ctr.values[0].blob->length, \ - (void **)discard_const(&(p)->elem), false); \ - if (_ret == -1) { \ + (void **)discard_const(&(p)->elem), &_ret, false)) { \ DEBUG(0,("%s: invalid data!\n", attr)); \ dump_data(0, \ _a->value_ctr.values[0].blob->data, \ diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index 965b85a13a..27c9a6c4a4 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -779,7 +779,6 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(struct ldb_context *ldb, W_ERROR_HAVE_NO_MEMORY(out->values); for (i=0; i < out->num_values; i++) { - ssize_t ret; char *str; if (in->value_ctr.values[i].blob == NULL) { @@ -790,13 +789,12 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(struct ldb_context *ldb, return WERR_FOOBAR; } - ret = convert_string_talloc_convenience(out->values, + if (!convert_string_talloc_convenience(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data, in->value_ctr.values[i].blob->length, - (void **)&str, false); - if (ret == -1) { + (void **)&str, NULL, false)) { return WERR_FOOBAR; } @@ -835,11 +833,10 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(struct ldb_context *ldb, out->value_ctr.values[i].blob = &blobs[i]; - ret = convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, + if (!convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, - (void **)&blobs[i].data, false); - if (ret == -1) { + (void **)&blobs[i].data, NULL, false)) { return WERR_FOOBAR; } blobs[i].length = ret; @@ -1145,7 +1142,6 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(struct ldb_context for (i=0; i < out->num_values; i++) { uint32_t len; - ssize_t ret; char *str; if (in->value_ctr.values[i].blob == NULL) { @@ -1162,11 +1158,10 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(struct ldb_context return WERR_FOOBAR; } - ret = convert_string_talloc_convenience(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX, + if (!convert_string_talloc_convenience(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data+4, in->value_ctr.values[i].blob->length-4, - (void **)&str, false); - if (ret == -1) { + (void **)&str, NULL, false)) { return WERR_FOOBAR; } @@ -1202,15 +1197,14 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(struct ldb_context for (i=0; i < in->num_values; i++) { uint8_t *data; - ssize_t ret; + size_t ret; out->value_ctr.values[i].blob = &blobs[i]; - ret = convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, + if (!convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, - (void **)&data, false); - if (ret == -1) { + (void **)&data, &ret, false)) { return WERR_FOOBAR; } diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c index 85e248dceb..8f2cb68129 100644 --- a/source4/kdc/kpasswdd.c +++ b/source4/kdc/kpasswdd.c @@ -61,12 +61,11 @@ static bool kpasswdd_make_error_reply(struct kdc_server *kdc, DATA_BLOB *error_blob) { char *error_string_utf8; - ssize_t len; + size_t len; DEBUG(result_code ? 3 : 10, ("kpasswdd: %s\n", error_string)); - len = push_utf8_talloc(mem_ctx, &error_string_utf8, error_string); - if (len == -1) { + if (!push_utf8_talloc(mem_ctx, &error_string_utf8, error_string, &len)) { return false; } @@ -219,7 +218,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc, DATA_BLOB *reply) { struct auth_session_info *session_info; - ssize_t pw_len; + size_t pw_len; if (!NT_STATUS_IS_OK(gensec_session_info(gensec_security, &session_info))) { @@ -233,13 +232,11 @@ static bool kpasswd_process_request(struct kdc_server *kdc, case KRB5_KPASSWD_VERS_CHANGEPW: { DATA_BLOB password; - pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), + if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), CH_UTF8, CH_UTF16, (const char *)input->data, input->length, - (void **)&password.data, false); - - if (pw_len == -1) { + (void **)&password.data, &pw_len, false)) { return false; } password.length = pw_len; @@ -281,12 +278,11 @@ static bool kpasswd_process_request(struct kdc_server *kdc, reply); } - pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), + if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), CH_UTF8, CH_UTF16, (const char *)chpw.newpasswd.data, chpw.newpasswd.length, - (void **)&password.data, false); - if (pw_len == -1) { + (void **)&password.data, &pw_len, false)) { free_ChangePasswdDataMS(&chpw); return false; } diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 41fbd22335..c558805e04 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -60,9 +60,9 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, case REG_SZ: case REG_EXPAND_SZ: if (val != NULL) - data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, + convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, val->data, val->length, - (void **)&data->data, false); + (void **)&data->data, &data->length, false); else { data->data = NULL; data->length = 0; @@ -105,10 +105,10 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, case REG_SZ: case REG_EXPAND_SZ: if (data.data[0] != '\0') { - val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, + convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, (void *)data.data, data.length, - (void **)&val.data, false); + (void **)&val.data, &val.length, false); ldb_msg_add_value(msg, "data", &val, NULL); } else { ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL); diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c index 3a3c3e7747..3de7602e53 100644 --- a/source4/lib/registry/tests/generic.c +++ b/source4/lib/registry/tests/generic.c @@ -53,8 +53,8 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx) static bool test_reg_val_data_string_sz(struct torture_context *ctx) { DATA_BLOB db; - db.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, - "bla", 3, (void **)&db.data, false); + convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, + "bla", 3, (void **)&db.data, &db.length, false); torture_assert_str_equal(ctx, "bla", reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db), "sz failed"); @@ -88,10 +88,10 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx) static bool test_reg_val_description(struct torture_context *ctx) { DATA_BLOB data; - data.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, + convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "stationary traveller", strlen("stationary traveller"), - (void **)&data.data, false); + (void **)&data.data, &data.length, false); torture_assert_str_equal(ctx, "camel = REG_SZ : stationary traveller", reg_val_description(ctx, lp_iconv_convenience(ctx->lp_ctx), "camel", REG_SZ, data), "reg_val_description failed"); @@ -102,10 +102,10 @@ static bool test_reg_val_description(struct torture_context *ctx) static bool test_reg_val_description_nullname(struct torture_context *ctx) { DATA_BLOB data; - data.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, + convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "west berlin", strlen("west berlin"), - (void **)&data.data, false); + (void **)&data.data, &data.length, false); torture_assert_str_equal(ctx, "<No Name> = REG_SZ : west berlin", reg_val_description(ctx, lp_iconv_convenience(ctx->lp_ctx), NULL, REG_SZ, data), "description with null name failed"); diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index 742c3dca2f..a1897eff2e 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -65,7 +65,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, case REG_SZ: convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UTF16, CH_UNIX, data.data, data.length, - (void **)&ret, false); + (void **)&ret, NULL, false); return ret; case REG_BINARY: ret = data_blob_hex_string(mem_ctx, &data); @@ -123,9 +123,9 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, { case REG_SZ: case REG_EXPAND_SZ: - data->length = convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16, + convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16, data_str, strlen(data_str), - (void **)&data->data, false); + (void **)&data->data, &data->length, false); break; case REG_DWORD: { diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c index 93f1329ea9..8b62ea0c2b 100644 --- a/source4/lib/tdr/tdr.c +++ b/source4/lib/tdr/tdr.c @@ -130,7 +130,7 @@ NTSTATUS tdr_print_uint32(struct tdr_print *tdr, const char *name, uint32_t *v) NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, uint32_t length, uint32_t el_size, charset_t chset) { - int ret; + size_t ret; if (length == -1) { switch (chset) { @@ -153,9 +153,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, TDR_PULL_NEED_BYTES(tdr, el_size*length); - ret = convert_string_talloc_convenience(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v), false); - - if (ret == -1) { + if (!convert_string_talloc_convenience(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v), &ret, false)) { return NT_STATUS_INVALID_PARAMETER; } @@ -166,7 +164,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, uint32_t el_size, charset_t chset) { - ssize_t ret, required; + size_t ret, required; if (length == -1) { length = strlen(*v) + 1; /* Extra element for null character */ @@ -175,9 +173,7 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, required = el_size * length; TDR_PUSH_NEED_BYTES(tdr, required); - ret = convert_string_convenience(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required, false); - - if (ret == -1) { + if (!convert_string_convenience(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required, &ret, false)) { return NT_STATUS_INVALID_PARAMETER; } diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index bbb363e0dd..c6118c6568 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -63,11 +63,12 @@ bool SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24]) bool E_md4hash(const char *passwd, uint8_t p16[16]) { - int len; - void *wpwd; + size_t len; + smb_ucs2_t *wpwd; + bool ret; - len = push_ucs2_talloc(NULL, &wpwd, passwd); - if (len < 2) { + ret = push_ucs2_talloc(NULL, &wpwd, passwd, &len); + if (!ret || len < 2) { /* We don't want to return fixed data, as most callers * don't check */ mdfour(p16, (const uint8_t *)passwd, strlen(passwd)); @@ -75,7 +76,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16]) } len -= 2; - mdfour(p16, wpwd, len); + mdfour(p16, (const uint8_t *)wpwd, len); talloc_free(wpwd); return true; @@ -116,10 +117,11 @@ bool ntv2_owf_gen(const uint8_t owf[16], bool upper_case_domain, /* Transform the domain into UPPER case */ uint8_t kr_buf[16]) { - void *user; - void *domain; + smb_ucs2_t *user; + smb_ucs2_t *domain; size_t user_byte_len; size_t domain_byte_len; + bool ret; HMACMD5Context ctx; TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in); @@ -150,15 +152,15 @@ bool ntv2_owf_gen(const uint8_t owf[16], } } - user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in); - if (user_byte_len == (ssize_t)-1) { + ret = push_ucs2_talloc(mem_ctx, &user, user_in, &user_byte_len ); + if (!ret) { DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n")); talloc_free(mem_ctx); return false; } - domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in); - if (domain_byte_len == (ssize_t)-1) { + ret = push_ucs2_talloc(mem_ctx, &domain, domain_in, &domain_byte_len); + if (!ret) { DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n")); talloc_free(mem_ctx); return false; @@ -172,14 +174,14 @@ bool ntv2_owf_gen(const uint8_t owf[16], domain_byte_len = domain_byte_len - 2; hmac_md5_init_limK_to_64(owf, 16, &ctx); - hmac_md5_update(user, user_byte_len, &ctx); - hmac_md5_update(domain, domain_byte_len, &ctx); + hmac_md5_update((const void *)user, user_byte_len, &ctx); + hmac_md5_update((const void *)domain, domain_byte_len, &ctx); hmac_md5_final(kr_buf, &ctx); #ifdef DEBUG_PASSWORD DEBUG(100, ("ntv2_owf_gen: user, domain, owfkey, kr\n")); - dump_data(100, user, user_byte_len); - dump_data(100, domain, domain_byte_len); + dump_data(100, (const void *)user, user_byte_len); + dump_data(100, (const void *)domain, domain_byte_len); dump_data(100, owf, 16); dump_data(100, kr_buf, 16); #endif diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index b8f4e5116c..09ecb40002 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -49,7 +49,7 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx, while (blob.length - ofs >= 24) { uint_t n = io->num_streams; uint32_t nlen, len; - ssize_t size; + bool ret; void *vstr; io->streams = talloc_realloc(mem_ctx, io->streams, struct stream_struct, n+1); @@ -62,10 +62,10 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx, if (nlen > blob.length - (ofs + 24)) { return NT_STATUS_INFO_LENGTH_MISMATCH; } - size = convert_string_talloc(io->streams, + ret = convert_string_talloc(io->streams, CH_UTF16, CH_UNIX, - blob.data+ofs+24, nlen, &vstr, false); - if (size == -1) { + blob.data+ofs+24, nlen, &vstr, NULL, false); + if (!ret) { return NT_STATUS_ILLEGAL_CHARACTER; } io->streams[n].stream_name.s = (const char *)vstr; diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index 5b461b47fd..0f04190a8b 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -558,7 +558,8 @@ static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX * char **dest, const uint8_t *src, int byte_len, uint_t flags) { int src_len, src_len2, alignment=0; - ssize_t ret; + bool ret; + size_t ret_size; if (!(flags & STR_NOALIGN) && ucs2_align(bufinfo->align_base, src, flags)) { src++; @@ -585,8 +586,8 @@ static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX * return 0; } - ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest, false); - if (ret == -1) { + ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest, &ret_size, false); + if (!ret) { *dest = NULL; return 0; } @@ -611,7 +612,8 @@ size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ct char **dest, const uint8_t *src, int byte_len, uint_t flags) { int src_len, src_len2; - ssize_t ret; + bool ret; + size_t ret_size; src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data); if (src_len < 0) { @@ -627,14 +629,14 @@ size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ct src_len2++; } - ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)dest, false); + ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)dest, &ret_size, false); - if (ret == -1) { + if (!ret) { *dest = NULL; return 0; } - return ret; + return ret_size; } /** @@ -752,7 +754,8 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, const uint8_t *src, int byte_len, uint_t flags) { int src_len, src_len2, alignment=0; - ssize_t ret; + size_t ret_size; + bool ret; char *dest2; if (src < blob->data || @@ -780,8 +783,8 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, src_len2 = utf16_len_n(src, src_len); - ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, false); - if (ret == -1) { + ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, &ret_size, false); + if (!ret) { *dest = NULL; return 0; } @@ -808,7 +811,8 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, const uint8_t *src, int byte_len, uint_t flags) { int src_len, src_len2; - ssize_t ret; + size_t ret_size; + bool ret; char *dest2; src_len = blob->length - PTR_DIFF(src, blob->data); @@ -826,15 +830,15 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, src_len2++; } - ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2, false); + ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2, &ret_size, false); - if (ret == -1) { + if (!ret) { *dest = NULL; return 0; } *dest = dest2; - return ret; + return ret_size; } /** diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index 19a2862d68..649a1db8d5 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -656,8 +656,8 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me { DATA_BLOB blob; NTSTATUS status; - ssize_t size; void *vstr; + bool ret; status = smb2_pull_o16s16_blob(buf, mem_ctx, ptr, &blob); NT_STATUS_NOT_OK_RETURN(status); @@ -675,11 +675,11 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me return NT_STATUS_OK; } - size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, - blob.data, blob.length, &vstr, false); + ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + blob.data, blob.length, &vstr, NULL, false); data_blob_free(&blob); (*str) = (char *)vstr; - if (size == -1) { + if (!ret) { return NT_STATUS_ILLEGAL_CHARACTER; } return NT_STATUS_OK; @@ -694,7 +694,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf, { DATA_BLOB blob; NTSTATUS status; - ssize_t size; + bool ret; if (str == NULL) { return smb2_push_o16s16_blob(buf, ofs, data_blob(NULL, 0)); @@ -706,12 +706,12 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf, return smb2_push_o16s16_blob(buf, ofs, blob); } - size = convert_string_talloc(buf->buffer, CH_UNIX, CH_UTF16, - str, strlen(str), (void **)&blob.data, false); - if (size == -1) { + ret = convert_string_talloc(buf->buffer, CH_UNIX, CH_UTF16, + str, strlen(str), (void **)&blob.data, &blob.length, + false); + if (!ret) { return NT_STATUS_ILLEGAL_CHARACTER; } - blob.length = size; status = smb2_push_o16s16_blob(buf, ofs, blob); data_blob_free(&blob); diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index 04a73c53ff..10a14655f3 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -185,9 +185,9 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, if (strcasecmp_m(s->name, secret_name) != 0) { continue; } - if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX, + if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX, s->secret.data, s->secret.length, - (void **)&secret_string, false) == -1) { + (void **)&secret_string, NULL, false)) { r->out.error_string = talloc_asprintf(mem_ctx, "Could not convert secret for domain %s to a string", t->name); diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 1ef1b0c13c..d6d996846e 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/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 ret; charset_t chset = CH_UTF16; unsigned byte_mul = 2; unsigned flags = ndr->flags; @@ -81,12 +81,11 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len2 + c_len_term)*byte_mul, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -118,13 +117,12 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len1 + c_len_term)*byte_mul, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -157,13 +155,12 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len1 + c_len_term)*byte_mul, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -192,13 +189,12 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len3 + c_len_term)*byte_mul, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -225,13 +221,12 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len3, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -246,12 +241,11 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -271,13 +265,12 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, - (void **)&as, false); - if (ret == -1) { + (void **)&as, &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -301,7 +294,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, */ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) { - ssize_t s_len, c_len, d_len; + size_t s_len, c_len, d_len; int chset = CH_UTF16; unsigned flags = ndr->flags; unsigned byte_mul = 2; @@ -334,8 +327,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, if (!(flags & LIBNDR_FLAG_STR_NOTERM)) { s_len++; } - d_len = convert_string_talloc_convenience(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest, false); - if (d_len == -1) { + if (!convert_string_talloc_convenience(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest, &d_len, false)) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -656,7 +648,7 @@ _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 ret; if (length == 0) { *var = talloc_strdup(ndr->current_mem_ctx, ""); return NDR_ERR_SUCCESS; @@ -668,13 +660,12 @@ _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_convenience(ndr->current_mem_ctx, + if (!convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, length*byte_mul, - discard_const_p(void *, var), false); - if (ret == -1) { + discard_const_p(void *, var), &ret, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } @@ -685,7 +676,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset) { - ssize_t ret, required; + size_t ret, required; if (NDR_BE(ndr) && chset == CH_UTF16) { chset = CH_UTF16BE; @@ -694,10 +685,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, required = byte_mul * length; NDR_PUSH_NEED_BYTES(ndr, required); - ret = convert_string_convenience(ndr->iconv_convenience, CH_UNIX, chset, + if (!convert_string_convenience(ndr->iconv_convenience, CH_UNIX, chset, var, strlen(var), - ndr->data+ndr->offset, required, false); - if (ret == -1) { + ndr->data+ndr->offset, required, &ret, false)) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c index 33a70fd478..f334eeb8f3 100644 --- a/source4/rpc_server/samr/samr_password.c +++ b/source4/rpc_server/samr/samr_password.c @@ -196,7 +196,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, DATA_BLOB lm_pwd_blob; uint8_t new_lm_hash[16]; struct samr_Password lm_verifier; - ssize_t unicode_pw_len; + size_t unicode_pw_len; if (pwbuf == NULL) { return NT_STATUS_INVALID_PARAMETER; @@ -251,22 +251,21 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, return NT_STATUS_WRONG_PASSWORD; } - if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), CH_DOS, CH_UNIX, (const char *)new_password.data, new_password.length, - (void **)&new_pass, false) == -1) { + (void **)&new_pass, NULL, false)) { DEBUG(3,("samr: failed to convert incoming password buffer to unix charset\n")); ldb_transaction_cancel(sam_ctx); return NT_STATUS_WRONG_PASSWORD; } - unicode_pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), CH_DOS, CH_UTF16, (const char *)new_password.data, new_password.length, - (void **)&new_unicode_password.data, false); - if (unicode_pw_len == -1) { + (void **)&new_unicode_password.data, &unicode_pw_len, false)) { DEBUG(3,("samr: failed to convert incoming password buffer to UTF16 charset\n")); ldb_transaction_cancel(sam_ctx); return NT_STATUS_WRONG_PASSWORD; @@ -429,11 +428,11 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, * this) */ if (lm_pwd && r->in.lm_verifier != NULL) { char *new_pass; - if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), CH_UTF16, CH_UNIX, (const char *)new_password.data, new_password.length, - (void **)&new_pass, false) != -1) { + (void **)&new_pass, NULL, false)) { E_deshash(new_pass, new_lm_hash); E_old_pw_hash(new_nt_hash, lm_pwd->hash, lm_verifier.hash); if (memcmp(lm_verifier.hash, r->in.lm_verifier->hash, 16) != 0) { diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index 377c5bf3cc..6846f80594 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -482,7 +482,7 @@ size_t req_append_var_block(struct smbsrv_request *req, static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags) { int src_len, src_len2, alignment=0; - ssize_t ret; + bool ret; char *dest2; if (!(flags & STR_NOALIGN) && ucs2_align(bufinfo->align_base, src, flags)) { @@ -513,9 +513,9 @@ static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, return src_len2 + alignment; } - ret = convert_string_talloc(bufinfo->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, false); + ret = convert_string_talloc(bufinfo->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, NULL, false); - if (ret == -1) { + if (!ret) { *dest = NULL; return 0; } @@ -540,7 +540,7 @@ static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, static size_t req_pull_ascii(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags) { int src_len, src_len2; - ssize_t ret; + bool ret; char *dest2; if (flags & STR_NO_RANGE_CHECK) { @@ -562,9 +562,9 @@ static size_t req_pull_ascii(struct request_bufinfo *bufinfo, const char **dest, src_len2++; } - ret = convert_string_talloc(bufinfo->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2, false); + ret = convert_string_talloc(bufinfo->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2, NULL, false); - if (ret == -1) { + if (!ret) { *dest = NULL; return 0; } diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c index 33ab2c9768..5ac299dbbe 100644 --- a/source4/torture/basic/charset.c +++ b/source4/torture/basic/charset.c @@ -42,7 +42,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx, { union smb_open io; char *fname, *fname2=NULL, *ucs_name; - int i; + size_t i; NTSTATUS status; ucs_name = talloc_size(mem_ctx, (1+u_name_len)*2); @@ -56,8 +56,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx, } SSVAL(ucs_name, i*2, 0); - i = convert_string_talloc_convenience(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname, false); - if (i == -1) { + if (!convert_string_talloc_convenience(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname, &i, false)) { torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n"); talloc_free(ucs_name); return NT_STATUS_NO_MEMORY; diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index ef0e4d44ed..ca6c2fd576 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -32,7 +32,8 @@ bool torture_utable(struct torture_context *tctx, const char *alt_name; int fnum; uint8_t c2[4]; - int c, len, fd; + int c, fd; + size_t len; int chars_allowed=0, alt_allowed=0; uint8_t valid[0x10000]; @@ -49,9 +50,9 @@ bool torture_utable(struct torture_context *tctx, SSVAL(c2, 0, c); strncpy(fname, "\\utable\\x", sizeof(fname)-1); p = fname+strlen(fname); - len = convert_string_convenience(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, + convert_string_convenience(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, c2, 2, - p, sizeof(fname)-strlen(fname), false); + p, sizeof(fname)-strlen(fname), &len, false); p[len] = 0; strncat(fname,"_a_long_extension",sizeof(fname)-1); @@ -102,15 +103,15 @@ static char *form_name(struct smb_iconv_convenience *iconv_convenience, int c) static char fname[256]; uint8_t c2[4]; char *p; - int len; + size_t len; strncpy(fname, "\\utable\\", sizeof(fname)-1); p = fname+strlen(fname); SSVAL(c2, 0, c); - len = convert_string_convenience(iconv_convenience, CH_UTF16, CH_UNIX, + convert_string_convenience(iconv_convenience, CH_UTF16, CH_UNIX, c2, 2, - p, sizeof(fname)-strlen(fname), false); + p, sizeof(fname)-strlen(fname), &len, false); p[len] = 0; return fname; } diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index c9e65cf493..7cacba7418 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -2537,7 +2537,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, memcpy(servername, r.out.info.info0.name, 16); servername[16] = '\0'; - if (pull_ascii_talloc(mem_ctx, name, servername) < 0) { + if (!pull_ascii_talloc(mem_ctx, name, servername, NULL)) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index 7e1744ffab..ce9bf5ea6e 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -1150,7 +1150,7 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea DATA_BLOB lm_response = data_blob(NULL, 0); char *password; char *dospw; - void *unicodepw; + smb_ucs2_t *unicodepw; uint8_t user_session_key[16]; uint8_t lm_key[16]; @@ -1161,8 +1161,8 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea ZERO_STRUCT(user_session_key); - if ((push_ucs2_talloc(samlogon_state->mem_ctx, - &unicodepw, samlogon_state->password)) == -1) { + if (!push_ucs2_talloc(samlogon_state->mem_ctx, + &unicodepw, samlogon_state->password, NULL)) { DEBUG(0, ("push_ucs2_allocate failed!\n")); exit(1); } @@ -1171,11 +1171,11 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea password = strupper_talloc(samlogon_state->mem_ctx, samlogon_state->password); - if ((convert_string_talloc_convenience(samlogon_state->mem_ctx, + if (!convert_string_talloc_convenience(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, CH_UNIX, CH_DOS, password, strlen(password)+1, - (void**)&dospw, false)) == -1) { + (void**)&dospw, NULL, false)) { DEBUG(0, ("convert_string_talloc failed!\n")); exit(1); } diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c index b09c62479c..08fadafe2c 100644 --- a/source4/torture/rpc/spoolss_win.c +++ b/source4/torture/rpc/spoolss_win.c @@ -383,7 +383,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx, convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, epk.out.key_buffer, *epk.out.needed, - (void**)&ctx->printer_keys, false); + (void**)&ctx->printer_keys, NULL, false); return true; } diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index 0f49562d8b..3c34229dff 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -966,7 +966,7 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx, size_t size; uint8_t *msg; - size = push_ucs2_talloc(tctx, (void **)&msg, message); + push_ucs2_talloc(tctx, (void **)&msg, message, &size); r.in.server_name = dcerpc_server_name(p); r.in.message_name = dcerpc_server_name(p); |