diff options
author | Jeremy Allison <jra@samba.org> | 2004-03-11 00:31:47 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-03-11 00:31:47 +0000 |
commit | 83560bfcfae6d2de0c29b7ac4e012e4bbe911c8f (patch) | |
tree | 48dcb7a7441ec1ade2fdad722b2da0cdd35b66bc /source3/smbd | |
parent | 2c2142d9d711a5bc638dd899fba7cda778561850 (diff) | |
download | samba-83560bfcfae6d2de0c29b7ac4e012e4bbe911c8f.tar.gz samba-83560bfcfae6d2de0c29b7ac4e012e4bbe911c8f.tar.bz2 samba-83560bfcfae6d2de0c29b7ac4e012e4bbe911c8f.zip |
Fix processing of pathnames with embedded '\\' characters (0x5c) in CP932
character set. Because of the allowing of "broken conversions" for people
who have broken iconv libraries we can't rely on the return from convert_string()
to be valid - we must check errno instead. This is ripe for revisiting at
some stage. I prefer adding a bool parameter to all convert_string_XX varients
to specify if we will allow broken conversions or not. With "allow_broken_conversions"
set to false we could then rely on the return from convert_string rather than
checking errno.
Jeremy.
(This used to be commit 74722f28659ac369676e898fda48d3d9ab265045)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/reply.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 5bf8ca0a2d..dc9f0be401 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -45,7 +45,7 @@ extern BOOL global_encrypted_passwords_negotiated; set. ****************************************************************************/ -static NTSTATUS check_path_syntax(pstring destname, const pstring srcname) +NTSTATUS check_path_syntax(pstring destname, const pstring srcname) { char *d = destname; const char *s = srcname; @@ -122,12 +122,30 @@ static NTSTATUS check_path_syntax(pstring destname, const pstring srcname) */ uint16 ucs2_val; - if (convert_string(CH_UNIX, CH_UCS2, s, 1, &ucs2_val, 2) == 2) { + + /* + * We know the following will return 2 bytes. What + * we need to know was if errno was set. + * Note that if CH_UNIX is utf8 a string may be 3 + * bytes, but this is ok as mb utf8 characters don't + * contain embedded directory separators. We are really checking + * for mb UNIX asian characters like Japanese (SJIS) here. + * JRA. + */ + + errno = 0; + convert_string(CH_UNIX, CH_UCS2, s, 1, &ucs2_val, 2); + if (errno == 0) { ; - } else if (convert_string(CH_UNIX, CH_UCS2, s, 2, &ucs2_val, 2) == 2) { - *d++ = *s++; } else { - smb_panic("check_path_syntax: directory separator assumptions invalid !\n"); + errno = 0; + convert_string(CH_UNIX, CH_UCS2, s, 2, &ucs2_val, 2); + if (errno == 0) { + *d++ = *s++; + } else { + DEBUG(0,("check_path_syntax: directory separator assumptions invalid !\n")); + return NT_STATUS_INVALID_PARAMETER; + } } } /* Just copy the char (or the second byte of the mb char). */ |