Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Duy Nguyen
On Fri, Mar 29, 2013 at 4:48 AM, Jeff King p...@peff.net wrote: - return fnmatch_icase(pattern, name, FNM_PATHNAME) == 0; + return fnmatch_icase_mem(pattern, patternlen, +name, namelen, +FNM_PATHNAME) == 0; } I

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Duy Nguyen
On Fri, Mar 29, 2013 at 3:45 PM, Duy Nguyen pclo...@gmail.com wrote: On Fri, Mar 29, 2013 at 4:48 AM, Jeff King p...@peff.net wrote: - return fnmatch_icase(pattern, name, FNM_PATHNAME) == 0; + return fnmatch_icase_mem(pattern, patternlen, +name,

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Torsten Bögershausen
On 29.03.13 11:03, Duy Nguyen wrote: On Fri, Mar 29, 2013 at 3:45 PM, Duy Nguyen pclo...@gmail.com wrote: On Fri, Mar 29, 2013 at 4:48 AM, Jeff King p...@peff.net wrote: - return fnmatch_icase(pattern, name, FNM_PATHNAME) == 0; + return fnmatch_icase_mem(pattern, patternlen, +

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Duy Nguyen
On Fri, Mar 29, 2013 at 6:32 PM, Torsten Bögershausen tbo...@web.de wrote: Just tested. t0003 and t3001 on 'pu' work for me because I have USE_WILDMATCH on (which turns FNM_PATHNAME to WM_PATHNAME). Both break without USE_WILDMATCH. Hm, tested what? Tested t0003 and t3001 with and without

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Jeff King
On Fri, Mar 29, 2013 at 03:45:35PM +0700, Nguyen Thai Ngoc Duy wrote: On Fri, Mar 29, 2013 at 4:48 AM, Jeff King p...@peff.net wrote: - return fnmatch_icase(pattern, name, FNM_PATHNAME) == 0; + return fnmatch_icase_mem(pattern, patternlen, +name,

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Duy Nguyen
On Fri, Mar 29, 2013 at 08:05:40AM -0400, Jeff King wrote: On Fri, Mar 29, 2013 at 03:45:35PM +0700, Nguyen Thai Ngoc Duy wrote: On Fri, Mar 29, 2013 at 4:48 AM, Jeff King p...@peff.net wrote: - return fnmatch_icase(pattern, name, FNM_PATHNAME) == 0; + return

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Junio C Hamano
Duy Nguyen pclo...@gmail.com writes: So we would want to do any adjustment to the fix when we merge up to maint. OK. Then Junio, you may need to resolve the conflict with something like this. Originally match_basename uses fnmatch, not wildmatch. But using wildmatch there too should be

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Jeff King
On Fri, Mar 29, 2013 at 09:44:32AM -0700, Junio C Hamano wrote: Duy Nguyen pclo...@gmail.com writes: So we would want to do any adjustment to the fix when we merge up to maint. OK. Then Junio, you may need to resolve the conflict with something like this. Originally match_basename

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Fri, Mar 29, 2013 at 09:44:32AM -0700, Junio C Hamano wrote: ... With the merge-fix, fnmatch_icase_mem() calls into wildmatch(), but fnmatch_icase() still calls into fnmatch(). The latter's flags are meant to be taken from FNM_* family, but the former

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Jeff King
On Fri, Mar 29, 2013 at 10:35:17AM -0700, Junio C Hamano wrote: This may be just the matter of naming. It smelled wrong to me only because the fnmatch in the helper fnmatch_icase_mem() told me that it should forever use fnmatch semantics. After reading its (only) two callsites, they are

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-29 Thread Duy Nguyen
On Fri, Mar 29, 2013 at 09:44:32AM -0700, Junio C Hamano wrote: I tend to think in the longer term it may be a good idea to build with USE_WILDMATCH unconditionally (we can lose compat/fnmatch), so in the end this may not matter that much I was thinking about that yesterday. After all, it's

Re: [PATCH 4/6] dir.c::match_pathname(): pay attention to the length of string parameters

2013-03-28 Thread Junio C Hamano
Jeff King p...@peff.net writes: This function takes two counted strings: a pattern, patternlen pair and a pathname, pathlen pair. But we end up feeding the result to fnmatch, which expects NUL-terminated strings. We can fix this by calling the fnmatch_icase_mem function, which handles