summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/auth/ntlmssp_parse.c4
-rw-r--r--source4/libcli/raw/rawrequest.c13
-rw-r--r--source4/libcli/util/smbencrypt.c44
3 files changed, 29 insertions, 32 deletions
diff --git a/source4/libcli/auth/ntlmssp_parse.c b/source4/libcli/auth/ntlmssp_parse.c
index 9c4cc40acf..22ed783666 100644
--- a/source4/libcli/auth/ntlmssp_parse.c
+++ b/source4/libcli/auth/ntlmssp_parse.c
@@ -64,7 +64,7 @@ BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
case 'U':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ucs2_talloc(pointers, (smb_ucs2_t **)&pointers[i].data, s);
+ n = push_ucs2_talloc(pointers, &pointers[i].data, s);
if (n == -1) {
return False;
}
@@ -87,7 +87,7 @@ BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
n = va_arg(ap, int);
intargs[i] = n;
s = va_arg(ap, char *);
- n = push_ucs2_talloc(pointers, (smb_ucs2_t **)&pointers[i].data, s);
+ n = push_ucs2_talloc(pointers, &pointers[i].data, s);
if (n == -1) {
return False;
}
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index a15d681a5c..89155451da 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -517,11 +517,7 @@ static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_c
src_len = byte_len;
}
- src_len2 = strnlen_w((const smb_ucs2_t *)src, src_len/2) * 2;
- if (src_len2 < src_len - 2) {
- /* include the termination if we didn't reach the end of the packet */
- src_len2 += 2;
- }
+ src_len2 = utf16_len_n(src, src_len);
/* ucs2 strings must be at least 2 bytes long */
if (src_len2 < 2) {
@@ -722,12 +718,7 @@ static size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx,
return 0;
}
- src_len2 = strnlen_w((const smb_ucs2_t *)src, src_len/2) * 2;
-
- if (src_len2 < src_len - 2) {
- /* include the termination if we didn't reach the end of the packet */
- src_len2 += 2;
- }
+ src_len2 = utf16_len_n(src, src_len);
ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
if (ret == -1) {
diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c
index f0dba16a5a..1089c3a4cf 100644
--- a/source4/libcli/util/smbencrypt.c
+++ b/source4/libcli/util/smbencrypt.c
@@ -61,17 +61,15 @@ BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
void E_md4hash(const char *passwd, uint8_t p16[16])
{
int len;
- smb_ucs2_t *wpwd;
-
- TALLOC_CTX *mem_ctx = talloc_init("E_md4hash");
- SMB_ASSERT(mem_ctx);
+ void *wpwd;
- len = push_ucs2_talloc(mem_ctx, &wpwd, passwd);
+ len = push_ucs2_talloc(NULL, &wpwd, passwd);
SMB_ASSERT(len >= 2);
len -= 2;
- mdfour(p16, (uint8_t *)wpwd, len);
- talloc_free(mem_ctx);
+ mdfour(p16, wpwd, len);
+
+ talloc_free(wpwd);
}
/**
@@ -109,9 +107,8 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
BOOL upper_case_domain, /* Transform the domain into UPPER case */
uint8_t kr_buf[16])
{
- smb_ucs2_t *user;
- smb_ucs2_t *domain;
-
+ void *user;
+ void *domain;
size_t user_byte_len;
size_t domain_byte_len;
@@ -121,6 +118,20 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
return False;
}
+ user_in = strupper_talloc(mem_ctx, user_in);
+ if (user_in == NULL) {
+ talloc_free(mem_ctx);
+ return False;
+ }
+
+ if (upper_case_domain) {
+ domain_in = strupper_talloc(mem_ctx, domain_in);
+ if (domain_in == NULL) {
+ talloc_free(mem_ctx);
+ return False;
+ }
+ }
+
user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in);
if (user_byte_len == (ssize_t)-1) {
DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
@@ -135,11 +146,6 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
return False;
}
- strupper_w(user);
-
- if (upper_case_domain)
- strupper_w(domain);
-
SMB_ASSERT(user_byte_len >= 2);
SMB_ASSERT(domain_byte_len >= 2);
@@ -148,14 +154,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((const uint8_t *)user, user_byte_len, &ctx);
- hmac_md5_update((const uint8_t *)domain, domain_byte_len, &ctx);
+ hmac_md5_update(user, user_byte_len, &ctx);
+ hmac_md5_update(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, (const char *)user, user_byte_len);
- dump_data(100, (const char *)domain, domain_byte_len);
+ dump_data(100, user, user_byte_len);
+ dump_data(100, domain, domain_byte_len);
dump_data(100, owf, 16);
dump_data(100, kr_buf, 16);
#endif