From 612738a9e14b6fb6a2687993d6416bbe6c3ea94d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 May 2000 22:47:09 +0000 Subject: lib/util_unistr.c: libsmb/clilist.c: rpc_server/srv_spoolss_nt.c: smbd/trans2.c: Changed unistr_to_ascii to unistr_to_dos - do codepage conversion. msdfs/msdfs.c: Removed stub unistr_to_dos. libsmb/pwd_cache.c: Removed obfuscation functions as they don't do anything and don't add any security. Jeremy. (This used to be commit 1ed146467e764e6a81d8f78cd58fb5765ebf5d21) --- source3/lib/util_unistr.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'source3/lib/util_unistr.c') diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 0ca148ba94..4a66adc0fd 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -91,7 +91,7 @@ int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate) Help ! Fix Me ! Fix Me ! ********************************************************************/ -void ascii_to_unistr(char *dest, const char *src, int maxlen) +void ascii_to_unistr(char *dest, const char *src, size_t maxlen) { char *destend = dest + maxlen; char c; @@ -107,24 +107,28 @@ void ascii_to_unistr(char *dest, const char *src, int maxlen) } /******************************************************************* - Pull an ASCII string out of a UNICODE array . - - Warning: doesn't do any codepage !!! BAD !!! - - Help ! Fix Me ! Fix Me ! + Pull a DOS codepage string out of a UNICODE array. len is in bytes. ********************************************************************/ -void unistr_to_ascii(char *dest, char *src, int len) +void unistr_to_dos(char *dest, char *src, size_t len) { char *destend = dest + len; - uint16 c; while (dest < destend) { - c = SVAL(src, 0); + uint16 ucs2_val = SVAL(src,0); + uint16 cp_val = ucs2_to_doscp[ucs2_val]; + src += 2; - if (c == 0) break; - *(dest++) = (char)c; + if (ucs2_val == 0) + break; + + if (cp_val < 256) + *dest++ = (char)cp_val; + else { + *dest++ = (cp_val >> 8) & 0xff; + *dest++ = (cp_val & 0xff); + } } *dest = 0; -- cgit