summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-05-10 22:47:09 +0000
committerJeremy Allison <jra@samba.org>2000-05-10 22:47:09 +0000
commit612738a9e14b6fb6a2687993d6416bbe6c3ea94d (patch)
tree55a78e514091bf38c7bd7cc445aade76338942af
parent2c978311dcb869b91a7787feba7f537056f4b90d (diff)
downloadsamba-612738a9e14b6fb6a2687993d6416bbe6c3ea94d.tar.gz
samba-612738a9e14b6fb6a2687993d6416bbe6c3ea94d.tar.bz2
samba-612738a9e14b6fb6a2687993d6416bbe6c3ea94d.zip
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)
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/lib/util_unistr.c26
-rw-r--r--source3/libsmb/clilist.c2
-rw-r--r--source3/libsmb/pwd_cache.c48
-rw-r--r--source3/msdfs/msdfs.c16
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c4
-rw-r--r--source3/smbd/trans2.c2
7 files changed, 21 insertions, 83 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 626820ae0e..de27782fde 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -496,8 +496,8 @@ char *string_truncate(char *s, int length);
/*The following definitions come from lib/util_unistr.c */
int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate);
-void ascii_to_unistr(char *dest, const char *src, int maxlen);
-void unistr_to_ascii(char *dest, char *src, int len);
+void ascii_to_unistr(char *dest, const char *src, size_t maxlen);
+void unistr_to_dos(char *dest, char *src, size_t len);
char *skip_unibuf(char *src, size_t len);
char *dos_unistrn2(uint16 *src, int len);
char *dos_unistr2(uint16 *src);
@@ -771,7 +771,6 @@ BOOL remote_password_change(const char *remote_machine, const char *user_name,
/*The following definitions come from libsmb/pwd_cache.c */
void pwd_init(struct pwd_info *pwd);
-void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key);
BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2);
void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt);
void pwd_set_nullpwd(struct pwd_info *pwd);
@@ -881,7 +880,6 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
int dfs_path_error(char* inbuf, char* outbuf);
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata);
-void unistr_to_dos(char* dst,char* src) ;
/*The following definitions come from msdfs/msdfs_tdb.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;
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index f3e4033539..2e904e06b7 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -126,7 +126,7 @@ static int interpret_long_filename(int level,char *p,file_info *finfo)
p += 2;
if (p[1] == 0 && slen > 1) {
/* NT has stuffed up again */
- unistr_to_ascii(finfo->short_name, p, slen/2);
+ unistr_to_dos(finfo->short_name, p, slen/2);
} else {
strncpy(finfo->short_name, p, 12);
finfo->short_name[12] = 0;
diff --git a/source3/libsmb/pwd_cache.c b/source3/libsmb/pwd_cache.c
index 4f02c42efb..1c5f8b5176 100644
--- a/source3/libsmb/pwd_cache.c
+++ b/source3/libsmb/pwd_cache.c
@@ -41,46 +41,19 @@ void pwd_init(struct pwd_info *pwd)
}
/****************************************************************************
-de-obfuscates a password
-****************************************************************************/
-static void pwd_deobfuscate(struct pwd_info *pwd)
-{
-}
-
-/****************************************************************************
-obfuscates a password
-****************************************************************************/
-static void pwd_obfuscate(struct pwd_info *pwd)
-{
-}
-
-/****************************************************************************
-sets the obfuscation key info
-****************************************************************************/
-void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key)
-{
-}
-
-/****************************************************************************
compares two passwords. hmm, not as trivial as expected. hmm.
****************************************************************************/
BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2)
{
- pwd_deobfuscate(pwd1);
- pwd_deobfuscate(pwd2);
if (pwd1->cleartext && pwd2->cleartext)
{
if (strequal(pwd1->password, pwd2->password))
{
- pwd_obfuscate(pwd1);
- pwd_obfuscate(pwd2);
return True;
}
}
if (pwd1->null_pwd && pwd2->null_pwd)
{
- pwd_obfuscate(pwd1);
- pwd_obfuscate(pwd2);
return True;
}
@@ -94,8 +67,6 @@ BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2)
#endif
if (memcmp(pwd1->smb_nt_pwd, pwd2->smb_nt_pwd, 16) == 0)
{
- pwd_obfuscate(pwd1);
- pwd_obfuscate(pwd2);
return True;
}
#ifdef DEBUG_PASSWORD
@@ -105,13 +76,9 @@ BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2)
#endif
if (memcmp(pwd1->smb_lm_pwd, pwd2->smb_lm_pwd, 16) == 0)
{
- pwd_obfuscate(pwd1);
- pwd_obfuscate(pwd2);
return True;
}
}
- pwd_obfuscate(pwd1);
- pwd_obfuscate(pwd2);
return False;
}
@@ -164,8 +131,6 @@ void pwd_set_cleartext(struct pwd_info *pwd, char *clr)
pwd->cleartext = True;
pwd->null_pwd = False;
pwd->crypted = False;
-
- pwd_obfuscate(pwd);
}
/****************************************************************************
@@ -173,7 +138,6 @@ void pwd_set_cleartext(struct pwd_info *pwd, char *clr)
****************************************************************************/
void pwd_get_cleartext(struct pwd_info *pwd, char *clr)
{
- pwd_deobfuscate(pwd);
if (pwd->cleartext)
{
fstrcpy(clr, pwd->password);
@@ -183,7 +147,6 @@ void pwd_get_cleartext(struct pwd_info *pwd, char *clr)
{
clr[0] = 0;
}
- pwd_obfuscate(pwd);
}
/****************************************************************************
@@ -214,8 +177,6 @@ void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
pwd->null_pwd = False;
pwd->cleartext = False;
pwd->crypted = False;
-
- pwd_obfuscate(pwd);
}
/****************************************************************************
@@ -223,7 +184,6 @@ void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
****************************************************************************/
void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
{
- pwd_deobfuscate(pwd);
if (lm_pwd != NULL)
{
memcpy(lm_pwd, pwd->smb_lm_pwd, 16);
@@ -232,7 +192,6 @@ void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
{
memcpy(nt_pwd, pwd->smb_nt_pwd, 16);
}
- pwd_obfuscate(pwd);
}
/****************************************************************************
@@ -251,8 +210,6 @@ void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
pwd->null_pwd = False;
pwd->cleartext = False;
pwd->crypted = False;
-
- pwd_obfuscate(pwd);
}
/****************************************************************************
@@ -260,7 +217,6 @@ void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
****************************************************************************/
void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
{
- pwd_deobfuscate(pwd);
#ifdef DEBUG_PASSWORD
DEBUG(100,("client cryptkey: "));
@@ -286,8 +242,6 @@ void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
#endif
pwd->crypted = True;
-
- pwd_obfuscate(pwd);
}
/****************************************************************************
@@ -295,7 +249,6 @@ void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
****************************************************************************/
void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
{
- pwd_deobfuscate(pwd);
if (lm_owf != NULL)
{
memcpy(lm_owf, pwd->smb_lm_owf, 24);
@@ -304,5 +257,4 @@ void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
{
memcpy(nt_owf, pwd->smb_nt_owf, 24);
}
- pwd_obfuscate(pwd);
}
diff --git a/source3/msdfs/msdfs.c b/source3/msdfs/msdfs.c
index f1b19dfe02..aadc63f04e 100644
--- a/source3/msdfs/msdfs.c
+++ b/source3/msdfs/msdfs.c
@@ -438,19 +438,3 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
}
#endif
-
-/* Trivial fn that chops off upper bytes to convert unicode to dos */
-void unistr_to_dos(char* dst,char* src)
-{
- pstring s;
- int i=0;
-
- for(i=0;SVAL(src,i*2) && i<1024;i++)
- {
- s[i]= SVAL(src,i*2) & 0xff;
- }
- s[i]=0;
-
- safe_strcpy(dst,s,1024);
- DEBUG(10,("converted unistring to %s\n",s));
-}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 43f0c94987..34e459d72b 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -582,8 +582,8 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u
static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode)
{
- unistr_to_ascii(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31);
- unistr_to_ascii(nt_devmode->formname, (char *)devmode.formname.buffer, 31);
+ unistr_to_dos(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31);
+ unistr_to_dos(nt_devmode->formname, (char *)devmode.formname.buffer, 31);
nt_devmode->specversion=devmode.specversion;
nt_devmode->driverversion=devmode.driverversion;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 55c0b306b0..e0156c083d 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2118,7 +2118,7 @@ static int call_trans2getdfsreferral(connection_struct *conn, char* inbuf,
/* NT always sends in UNICODE, may not set UNICODE flag */
if(NT_arch || (SVAL(inbuf,smb_flg2) & FLAGS2_UNICODE_STRINGS))
{
- unistr_to_dos(pathname, &params[2]);
+ unistr_to_dos(pathname, &params[2], sizeof(pathname));
DEBUG(10,("UNICODE referral for %s\n",pathname));
}
else