Long filename mangling bug in smbd/mangle_hash.c
Jeremy Allison
jra at samba.org
Wed Dec 3 23:15:38 GMT 2003
On Tue, Dec 02, 2003 at 07:22:03PM -0700, Forrest W. Christian wrote:
> This is applicable to the released version of 3.0. It does not appear to
> have been fixed in CVS (at least according to cvsweb).
>
> I have discovered a bug which causes long filenames which do not need to
> be mangled to get mangled into 8.3 names.
Yep - valid bug. Thanks for the report. Can you try this patch ?
Thanks,
Jeremy.
-------------- next part --------------
? client_oplocks.txt
? security_server_segfault.patch
? lib/smbldap.c.mod
? smbd/.sesssetup.c.swp
Index: smbd/mangle_hash.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/mangle_hash.c,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 mangle_hash.c
--- smbd/mangle_hash.c 27 Jul 2003 02:28:25 -0000 1.1.2.8
+++ smbd/mangle_hash.c 3 Dec 2003 23:14:41 -0000
@@ -139,7 +139,7 @@
/* -------------------------------------------------------------------- */
-static NTSTATUS has_valid_chars(const smb_ucs2_t *s, BOOL allow_wildcards)
+static NTSTATUS has_valid_83_chars(const smb_ucs2_t *s, BOOL allow_wildcards)
{
if (!s || !*s)
return NT_STATUS_INVALID_PARAMETER;
@@ -176,7 +176,7 @@
if ((p = strrchr_w(*prefix, UCS2_CHAR('.')))) {
ext_len = strlen_w(p+1);
if ((ext_len > 0) && (ext_len < 4) && (p != *prefix) &&
- (NT_STATUS_IS_OK(has_valid_chars(p+1,allow_wildcards)))) /* check extension */ {
+ (NT_STATUS_IS_OK(has_valid_83_chars(p+1,allow_wildcards)))) /* check extension */ {
*p = 0;
*extension = strdup_w(p+1);
if (!*extension) {
@@ -200,7 +200,7 @@
* ************************************************************************** **
*/
-static NTSTATUS is_valid_name(const smb_ucs2_t *fname, BOOL allow_wildcards)
+static NTSTATUS is_valid_name(const smb_ucs2_t *fname, BOOL allow_wildcards, BOOL only_8_3)
{
smb_ucs2_t *str, *p;
NTSTATUS ret = NT_STATUS_OK;
@@ -216,9 +216,11 @@
if (*fname == UCS2_CHAR('.'))
return NT_STATUS_UNSUCCESSFUL;
- ret = has_valid_chars(fname, allow_wildcards);
- if (!NT_STATUS_IS_OK(ret))
- return ret;
+ if (only_8_3) {
+ ret = has_valid_83_chars(fname, allow_wildcards);
+ if (!NT_STATUS_IS_OK(ret))
+ return ret;
+ }
str = strdup_w(fname);
p = strchr_w(str, UCS2_CHAR('.'));
@@ -286,7 +288,7 @@
if (strcmp_wa(fname, ".") == 0 || strcmp_wa(fname, "..") == 0)
return NT_STATUS_OK;
- if (!NT_STATUS_IS_OK(is_valid_name(fname, allow_wildcards)))
+ if (!NT_STATUS_IS_OK(is_valid_name(fname, allow_wildcards, True)))
goto done;
if (!NT_STATUS_IS_OK(mangle_get_prefix(fname, &pref, &ext, allow_wildcards)))
@@ -737,7 +739,7 @@
return;
}
- if( !need83 && !NT_STATUS_IS_OK(is_valid_name(OutName_ucs2, False)))
+ if( !need83 && !NT_STATUS_IS_OK(is_valid_name(OutName_ucs2, False, False)))
need83 = True;
/* check if it's already in 8.3 format */
More information about the samba-technical
mailing list