summaryrefslogtreecommitdiff
path: root/libc/misc/fnmatch/fnmatch_loop.c
AgeCommit message (Collapse)Author
2023-11-10fnmatch: fix possible access beyond of parameter stringMarcus Haehnel
In certain cases, fnmatch() could access the next byte beyond the end of he passed pattern. A triggering pattern to match is the following invocation: fnmatch("[A-Z[.", "F", 0) The normal A-Z group match gets us to fnmatch_loop.c:421 and then to fnmatch_loop:599. The F in the filaname matches this expression and we end up in fnmatch_loop:867 which handles skipping the rest of a bracked expression that already matched. Here we enter the case where the next chars to parse are a collating symbol starting with "[." (fnmatch_loop:918). Currently the p pointer is then advanced by one, moving it beyond the "." and to the \0 byte of the pattern string (fnmatch_loop:920). Inside the while loop the pointer is then incremented again and immediately dereferenced, reaching beyond the end of the pattern string. The increment before the while loop must be removed, because only inside the while loop (after the other increment) a check for the end of the string is performend. This is sufficient and the check of the end of the collating symbol is only performed if p[1] is at most the terminating \0 byte. Signed-Off-By: Frank Mehnert <frank.mehnert@kernkonzept.com>
2021-12-24Fix -Wundef related warningsYann Sionneau
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2020-09-22Fix warning about missing const qualifierYann Sionneau
Fixes this: In file included from libc/misc/fnmatch/fnmatch.c:235:0: libc/misc/fnmatch/fnmatch_loop.c: In function 'internal_fnmatch': libc/misc/fnmatch/fnmatch_loop.c:207:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] CHAR *p_init = p; ^ libc/misc/fnmatch/fnmatch_loop.c:208:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] CHAR *n_init = n; Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2016-11-27Fix handling of unterminated [ expression in fnmatch.Waldemar Brodkorb
Originally fixed in GNU libc by: commit 794c3ad3a405697e2663b00f616e319383b9bb7d Author: Ulrich Drepper <drepper@gmail.com> Date: Fri Jan 14 08:06:22 2011 -0500 Reported-by: Denys Vlasenko <vda.linux@googlemail.com> via busybox mailinglist.
2012-11-18Replace FSF snail mail address with URLsMike Frysinger
This matches a similar change made to glibc. No functional changes here. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-06-15fnmatch: replace __memset and __memcmpPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2008-05-20- remove old-style definitions. No object-code changes.Bernhard Reutner-Fischer
2006-01-14hidden_def/hidden_proto: convert all users (I hope) termios split, add some ↵Peter S. Mazinger
missing headers, other jump relocs removed
2005-12-24Add new fnmatch code, for now mbstate_t and mbsrtowcs are depending on ↵Peter S. Mazinger
UCLIBC_HAS_LOCALE, making the new object about 5k, else it would be 10k