1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

Use common header file for character set handling in Samba 3 and Samba 4.

This commit is contained in:
Jelmer Vernooij 2009-03-01 22:24:34 +01:00
parent 94069bd274
commit 7ab8f373c8
15 changed files with 172 additions and 212 deletions

View File

@ -28,9 +28,16 @@
#include <talloc.h>
/* this defines the charset types used in samba */
typedef enum {CH_UTF16=0, CH_UNIX, CH_DOS, CH_UTF8, CH_UTF16BE, CH_UTF16MUNGED} charset_t;
typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX, CH_DISPLAY, CH_DOS, CH_UTF8, CH_UTF16BE, CH_UTF16MUNGED} charset_t;
#define NUM_CHARSETS 6
#define NUM_CHARSETS 7
/*
* SMB UCS2 (16-bit unicode) internal type.
* smb_ucs2_t is *always* in little endian format.
*/
typedef uint16_t smb_ucs2_t;
/*
* for each charset we have a function that pulls from that charset to
@ -51,6 +58,17 @@ typedef uint32_t codepoint_t;
#define INVALID_CODEPOINT ((codepoint_t)-1)
/*
* This is auxiliary struct used by source/script/gen-8-bit-gap.sh script
* during generation of an encoding table for charset module
* */
struct charset_gap_table {
uint16_t start;
uint16_t end;
int32_t idx;
};
/* generic iconv conversion structure */
typedef struct smb_iconv_s {
@ -106,12 +124,12 @@ bool strhaslower(const char *string);
char *strrchr_m(const char *s, char c);
char *strchr_m(const char *s, char c);
ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src);
ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src);
ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size);
bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src, size_t *converted_size);
bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags);
ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
@ -171,4 +189,81 @@ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
void load_case_tables(void);
bool charset_register_backend(const void *_funcs);
/*
* Define stub for charset module which implements 8-bit encoding with gaps.
* Encoding tables for such module should be produced from glibc's CHARMAPs
* using script source/script/gen-8bit-gap.sh
* CHARSETNAME is CAPITALIZED charset name
*
* */
#define SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CHARSETNAME) \
static size_t CHARSETNAME ## _push(void *cd, const char **inbuf, size_t *inbytesleft, \
char **outbuf, size_t *outbytesleft) \
{ \
while (*inbytesleft >= 2 && *outbytesleft >= 1) { \
int i; \
int done = 0; \
\
uint16 ch = SVAL(*inbuf,0); \
\
for (i=0; from_idx[i].start != 0xffff; i++) { \
if ((from_idx[i].start <= ch) && (from_idx[i].end >= ch)) { \
((unsigned char*)(*outbuf))[0] = from_ucs2[from_idx[i].idx+ch]; \
(*inbytesleft) -= 2; \
(*outbytesleft) -= 1; \
(*inbuf) += 2; \
(*outbuf) += 1; \
done = 1; \
break; \
} \
} \
if (!done) { \
errno = EINVAL; \
return -1; \
} \
\
} \
\
if (*inbytesleft == 1) { \
errno = EINVAL; \
return -1; \
} \
\
if (*inbytesleft > 1) { \
errno = E2BIG; \
return -1; \
} \
\
return 0; \
} \
\
static size_t CHARSETNAME ## _pull(void *cd, const char **inbuf, size_t *inbytesleft, \
char **outbuf, size_t *outbytesleft) \
{ \
while (*inbytesleft >= 1 && *outbytesleft >= 2) { \
*(uint16*)(*outbuf) = to_ucs2[((unsigned char*)(*inbuf))[0]]; \
(*inbytesleft) -= 1; \
(*outbytesleft) -= 2; \
(*inbuf) += 1; \
(*outbuf) += 2; \
} \
\
if (*inbytesleft > 0) { \
errno = E2BIG; \
return -1; \
} \
\
return 0; \
} \
\
struct charset_functions CHARSETNAME ## _functions = \
{#CHARSETNAME, CHARSETNAME ## _pull, CHARSETNAME ## _push}; \
\
NTSTATUS charset_ ## CHARSETNAME ## _init(void); \
NTSTATUS charset_ ## CHARSETNAME ## _init(void) \
{ \
return smb_register_charset(& CHARSETNAME ## _functions); \
} \
#endif /* __CHARSET_H__ */

View File

@ -22,6 +22,7 @@
#include "../lib/util/dlinklist.h"
#include "system/iconv.h"
#include "system/filesys.h"
#undef strcasecmp
/**

View File

@ -668,13 +668,11 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag
* @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
_PUBLIC_ bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1, ret;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, &ret, false))
return -1;
return (ssize_t)ret;
return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, converted_size, false);
}
@ -781,13 +779,11 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags
* @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
_PUBLIC_ bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1, ret;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, dest, &ret, false))
return -1;
return ret;
return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, (void **)dest, converted_size, false);
}
@ -799,13 +795,11 @@ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
* @returns The number of bytes occupied by the string in the destination
**/
_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
_PUBLIC_ bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1, ret;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, &ret, false))
return -1;
return ret;
return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, converted_size, false);
}
/**
@ -856,13 +850,11 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src
* @returns The number of bytes occupied by the string in the destination
**/
_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
_PUBLIC_ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1, ret;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, &ret, false))
return -1;
return ret;
return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
}
/**
@ -873,13 +865,11 @@ _PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src
* @returns The number of bytes occupied by the string in the destination
**/
_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
_PUBLIC_ bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src, size_t *converted_size)
{
size_t src_len = utf16_len(src), ret;
size_t src_len = utf16_len(src);
*dest = NULL;
if (!convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, &ret, false))
return -1;
return ret;
return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
}
/**
@ -890,13 +880,11 @@ _PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
* @returns The number of bytes occupied by the string in the destination
**/
_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
_PUBLIC_ bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1, ret;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, &ret, false))
return -1;
return ret;
return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
}
/**

View File

@ -366,8 +366,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
lib/substitute.o lib/dbwrap_util.o \
lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \
lib/iconv.o lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \
lib/adt_tree.o lib/gencache.o \
../lib/util/charset/iconv.o lib/pam_errors.o intl/lang_tdb.o \
lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
lib/ldap_escape.o @CHARSET_STATIC@ \
lib/secdesc.o lib/util_seaccess.o lib/secace.o lib/secacl.o \

View File

@ -1,128 +0,0 @@
/*
Unix SMB/CIFS implementation.
charset defines
Copyright (C) Andrew Tridgell 2001
Copyright (C) Jelmer Vernooij 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
struct smb_iconv_convenience;
/* this defines the charset types used in samba */
typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t;
#define NUM_CHARSETS 6
/*
* for each charset we have a function that pushes from that charset to a ucs2
* buffer, and a function that pulls from ucs2 buffer to that charset.
* */
struct charset_functions {
const char *name;
size_t (*pull)(void *, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
size_t (*push)(void *, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
struct charset_functions *prev, *next;
};
/*
* This is auxiliary struct used by source/script/gen-8-bit-gap.sh script
* during generation of an encoding table for charset module
* */
struct charset_gap_table {
uint16 start;
uint16 end;
int32 idx;
};
/*
* Define stub for charset module which implements 8-bit encoding with gaps.
* Encoding tables for such module should be produced from glibc's CHARMAPs
* using script source/script/gen-8bit-gap.sh
* CHARSETNAME is CAPITALIZED charset name
*
* */
#define SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CHARSETNAME) \
static size_t CHARSETNAME ## _push(void *cd, const char **inbuf, size_t *inbytesleft, \
char **outbuf, size_t *outbytesleft) \
{ \
while (*inbytesleft >= 2 && *outbytesleft >= 1) { \
int i; \
int done = 0; \
\
uint16 ch = SVAL(*inbuf,0); \
\
for (i=0; from_idx[i].start != 0xffff; i++) { \
if ((from_idx[i].start <= ch) && (from_idx[i].end >= ch)) { \
((unsigned char*)(*outbuf))[0] = from_ucs2[from_idx[i].idx+ch]; \
(*inbytesleft) -= 2; \
(*outbytesleft) -= 1; \
(*inbuf) += 2; \
(*outbuf) += 1; \
done = 1; \
break; \
} \
} \
if (!done) { \
errno = EINVAL; \
return -1; \
} \
\
} \
\
if (*inbytesleft == 1) { \
errno = EINVAL; \
return -1; \
} \
\
if (*inbytesleft > 1) { \
errno = E2BIG; \
return -1; \
} \
\
return 0; \
} \
\
static size_t CHARSETNAME ## _pull(void *cd, const char **inbuf, size_t *inbytesleft, \
char **outbuf, size_t *outbytesleft) \
{ \
while (*inbytesleft >= 1 && *outbytesleft >= 2) { \
*(uint16*)(*outbuf) = to_ucs2[((unsigned char*)(*inbuf))[0]]; \
(*inbytesleft) -= 1; \
(*outbytesleft) -= 2; \
(*inbuf) += 1; \
(*outbuf) += 2; \
} \
\
if (*inbytesleft > 0) { \
errno = E2BIG; \
return -1; \
} \
\
return 0; \
} \
\
struct charset_functions CHARSETNAME ## _functions = \
{#CHARSETNAME, CHARSETNAME ## _pull, CHARSETNAME ## _push}; \
\
NTSTATUS charset_ ## CHARSETNAME ## _init(void); \
NTSTATUS charset_ ## CHARSETNAME ## _init(void) \
{ \
return smb_register_charset(& CHARSETNAME ## _functions); \
} \

View File

@ -336,6 +336,7 @@ int bitmap_find(struct bitmap *bm, unsigned ofs);
/* The following definitions come from lib/charcnv.c */
NTSTATUS smb_register_charset(struct charset_functions *funcs);
char lp_failed_convert_char(void);
void lazy_initialize_conv(void);
void gfree_charcnv(void);

View File

@ -149,8 +149,6 @@ typedef union unid_t {
* smb_ucs2_t is *always* in little endian format.
*/
typedef uint16 smb_ucs2_t;
#ifdef WORDS_BIGENDIAN
#define UCS2_SHIFT 8
#else

View File

@ -763,7 +763,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
* converted.
*/
bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void *dst,
void const *src, size_t srclen, void **dst,
size_t *converted_size, bool allow_bad_conv)
{
void **dest = (void **)dst;

View File

@ -207,12 +207,12 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
from = charsets;
to = charsets;
ret = SMB_MALLOC_P(struct _smb_iconv_t);
ret = SMB_MALLOC_P(smb_iconv_t);
if (!ret) {
errno = ENOMEM;
return (smb_iconv_t)-1;
}
memset(ret, 0, sizeof(struct _smb_iconv_t));
memset(ret, 0, sizeof(smb_iconv_t));
ret->from_name = SMB_STRDUP(fromcode);
ret->to_name = SMB_STRDUP(tocode);

View File

@ -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':

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);