Bug 205 - wildcard matching with different length of upper/lower case
wildcard matching with different length of upper/lower case
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: Extended Characters
3.0.0preX
All All
: P2 normal
: none
Assigned To: Gerald (Jerry) Carter
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-07-06 08:00 UTC by TAKAHASHI Motonobu
Modified: 2005-08-24 10:22 UTC (History)
1 user (show)

See Also:


Attachments
Don't strlower for fnmatch (10.47 KB, patch)
2003-07-22 06:24 UTC, Andrew Bartlett
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description TAKAHASHI Motonobu 2003-07-06 08:00:40 UTC
If lower case of a character is longer than upper case of that,
then
-----
DIR <i>.*
-----
does not match even if <i>.TXT exists ( '<i>' is ONE character whose
lower case is longer than whose upper case of that).

Because in strlower_m at util_str.c:1138

        /* I assume that lowercased string takes the same number of bytes
         * as source string even in UTF-8 encoding. (VIV) */
        unix_strlower(s,strlen(s)+1,s,strlen(s)+1);

Please do not assume.

Now there are lots of messages like:

[2003/07/05 21:34:02, 0] lib/charcnv.c:convert_string(194)
  convert_string: Required 8, available 5

When I insert smb_panic() after that message and type:
-----
DIR <i>.*
-----
then the stack trace is:

[2003/07/05 21:34:02, 0] lib/util.c:smb_panic(1469)
  BACKTRACE: 15 stack frames:
   #0 bin/smbd(smb_panic+0x16b) [0x816d4e3]
   #1 bin/smbd(convert_string+0xf2) [0x815cb36]
   #2 bin/smbd(unix_strlower+0x78) [0x815cf0c]
   #3 bin/smbd(strlower_m+0x53) [0x81677f3]
   #4 bin/smbd(mask_match+0x95) [0x816eadd]
   #5 bin/smbd [0x80998e3]
   #6 bin/smbd [0x809ac4b]
   #7 bin/smbd(reply_trans2+0x6bc) [0x80a077c]
   #8 bin/smbd [0x80b09ee]
   #9 bin/smbd [0x80b0a8e]
   #10 bin/smbd(process_smb+0x187) [0x80b0d33]
   #11 bin/smbd(smbd_process+0x1b2) [0x80b16a2]
   #12 bin/smbd(main+0x6cb) [0x81b53af]
   #13 /lib/libc.so.6(__libc_start_main+0xbb) [0x4016114f]
   #14 bin/smbd(yp_get_default_domain+0x69) [0x8070de1]
Comment 1 Andrew Bartlett 2003-07-22 06:24:54 UTC
Created attachment 54 [details]
Don't strlower for fnmatch

This patch tries to avoid doing the strlower_m at all - instead we just do a
case-insentitive compare in the fnmatch code.

The fnmatch code is untested, as is the change to push_ucs2 (to make it cope
with 
this situation for the STR_UPPER flag).

StrCaseCmp is again tested with the software test framework.

Andrew Bartlett
Comment 2 Jeremy Allison 2003-08-11 21:31:05 UTC
I have committed a fix for this - similar to the suggested patch.
Jeremy.
Comment 3 Gerald (Jerry) Carter 2005-02-07 08:40:48 UTC
originally reported against 3.0.0beta2.  CLeaning out 
non-production release versions.
Comment 4 Gerald (Jerry) Carter 2005-08-24 10:22:11 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.