On Fri, Jul 31, 2015 at 12:58:47PM -0600, Todd C. Miller wrote:
> The problem is that classmatch() can change pattern so we need to
> check to see if it was consumed afterwards.
> 
>  - todd
> 
> Index: lib/libc/gen/fnmatch.c
> ===================================================================
> RCS file: /cvs/src/lib/libc/gen/fnmatch.c,v
> retrieving revision 1.18
> diff -u -p -u -r1.18 fnmatch.c
> --- lib/libc/gen/fnmatch.c    11 Dec 2014 16:25:34 -0000      1.18
> +++ lib/libc/gen/fnmatch.c    31 Jul 2015 18:55:18 -0000
> @@ -192,6 +192,7 @@ static int fnmatch_ch(const char **patte
>                  result = 0;
>                  continue;
>              }
> +            if (!**pattern) break;
>  
>  leadingclosebrace:
>              /* Look at only well-formed range patterns; 

That's much cleaner and I can confirm it fixes the issue.
Can we move the break on the next line? Apart from that, ok with me.


(Yes, I'm too lazy to find a better way to drive gdb than below...)

(gdb) br fnmatch.c:202
No source file named fnmatch.c.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (fnmatch.c:202) pending.
(gdb) run
Starting program: /tmp/test
Breakpoint 2 at 0x168232e6085c: file /usr/src/lib/libc/gen/fnmatch.c, line 202.
Pending breakpoint "fnmatch.c:202" resolved

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$1 = 58 ':'
(gdb) c
Continuing.

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$2 = 108 'l'
(gdb) c
Continuing.

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$3 = 111 'o'
(gdb) c
Continuing.

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$4 = 119 'w'
(gdb) c
Continuing.

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$5 = 101 'e'
(gdb) c
Continuing.

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$6 = 114 'r'
(gdb) c
Continuing.

Breakpoint 2, fnmatch_ch (pattern=0x7f7ffffe69b0, string=0x7f7ffffe69a8, 
flags=Variable "flags" is not available.

) at /usr/src/lib/libc/gen/fnmatch.c:202
202                 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
(gdb) p **pattern
$7 = 58 ':'
(gdb) c
Continuing.

Program exited with code 01.
(gdb)

Reply via email to