diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-03-01 22:24:34 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-03-01 22:24:34 +0100 |
commit | 7ab8f373c84c328b197f923287163e83371e7ccb (patch) | |
tree | 8a009647735ccc1cf181d98b01c1084f45e0d711 /source4 | |
parent | 94069bd2747a8397308c0b0b384f7bb4edd8f68b (diff) | |
download | samba-7ab8f373c84c328b197f923287163e83371e7ccb.tar.gz samba-7ab8f373c84c328b197f923287163e83371e7ccb.tar.bz2 samba-7ab8f373c84c328b197f923287163e83371e7ccb.zip |
Use common header file for character set handling in Samba 3 and Samba 4.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/auth/ntlmssp/ntlmssp_parse.c | 36 | ||||
-rw-r--r-- | source4/kdc/kpasswdd.c | 5 | ||||
-rw-r--r-- | source4/libcli/auth/smbencrypt.c | 32 | ||||
-rw-r--r-- | source4/torture/rpc/samba3rpc.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/samlogon.c | 6 | ||||
-rw-r--r-- | source4/torture/rpc/wkssvc.c | 2 |
6 files changed, 44 insertions, 39 deletions
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/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c index 67404af2ab..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; } 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/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 0f0b8dc84d..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); } 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); |