public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/18036] New: buffer overflow (read past end of buffer) in internal_fnmatch=>end_pattern with "**(!()" pattern
@ 2015-02-26 18:12 konstantin.s.serebryany at gmail dot com
  2015-02-26 18:22 ` [Bug libc/18036] " ppluzhnikov at google dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: konstantin.s.serebryany at gmail dot com @ 2015-02-26 18:12 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18036

            Bug ID: 18036
           Summary: buffer overflow (read past end of buffer) in
                    internal_fnmatch=>end_pattern with "**(!()" pattern
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: konstantin.s.serebryany at gmail dot com
                CC: drepper.fsp at gmail dot com
             Flags: security+

Similar to https://sourceware.org/bugzilla/show_bug.cgi?id=18032
but in a different place: 

#include <fnmatch.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <assert.h>
int main(int argc, const char* argv[]) {
  long page_size = sysconf (_SC_PAGESIZE);
  assert(page_size > 0);
  char *page = mmap (NULL, 2 * page_size, PROT_READ | PROT_WRITE,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  assert(page != MAP_FAILED);
  assert(!mprotect (page + page_size, page_size, PROT_NONE));
  memset (page, ' ', page_size);
  const char p[] = "**(!()";
  strcpy(page, p); 
  fnmatch(page, p, FNM_EXTMATCH);
} 


gcc fn3.c && ./a.out 
Segmentation fault (core dumped)


gdb: 
(gdb) bt
#0  0x00007ffff7adaf4b in end_pattern (pattern=pattern@entry=0x7ffff7ff6002
"(!()") at fnmatch_loop.c:1032
#1  0x00007ffff7adcbb9 in internal_fnmatch (pattern=<optimized out>,
string=string@entry=0x7fffffffdcd0 "**(!()", string_end=0x7fffffffdcd6 "",
no_leading_period=no_leading_period@entry=0, 
    flags=flags@entry=32, ends=ends@entry=0x0, alloca_used=alloca_used@entry=0)
at fnmatch_loop.c:128
#2  0x00007ffff7addf72 in __fnmatch (pattern=0x7ffff7ff6000 "**(!()",
string=0x7fffffffdcd0 "**(!()", flags=32) at fnmatch.c:458
#3  0x000000000040084a in main ()

Reproduces on 2.19 and fresh trunk. Marking as security+ similar to bug 18032
Since bug 18032 has been fixed promptly I assume you don't mind these reports.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-06-25 20:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 18:12 [Bug libc/18036] New: buffer overflow (read past end of buffer) in internal_fnmatch=>end_pattern with "**(!()" pattern konstantin.s.serebryany at gmail dot com
2015-02-26 18:22 ` [Bug libc/18036] " ppluzhnikov at google dot com
2015-02-28  5:07 ` ppluzhnikov at google dot com
2015-03-02 21:37 ` cvs-commit at gcc dot gnu.org
2015-03-02 21:38 ` ppluzhnikov at google dot com
2023-06-06 12:24 ` helmut at subdivi dot de
2023-06-25 20:38 ` carnil at debian dot org
2023-06-25 20:38 ` carnil at debian dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).