Bug 26620 - fnmatch with collating symbols results in segmentation fault
Summary: fnmatch with collating symbols results in segmentation fault
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: glob (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: 2.33
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-15 21:23 UTC by Harald van Dijk
Modified: 2020-11-11 12:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald van Dijk 2020-09-15 21:23:45 UTC
Consider this test program:

  #include <stdio.h>
  #include <locale.h>
  #include <fnmatch.h>
  int main(int argc, char *argv[]) {
    setlocale(LC_ALL, "");
    if (argc != 3) {
      fprintf(stderr, "usage: fnmatch <pattern> <string>\n");
      return 2;
    }
    return !!fnmatch(argv[1], argv[2], 0);
  }

When called as

  export LC_ALL=en_US.UTF-8
  ./fnmatch $'[[.L\u00B7.]]' . # [[.LĀ·.]]

This results in a segmentation fault in internal_fnwmatch.

Seen on glibc 2.32 built with GCC 10.2.0, also reproducible with the libc6-2.31-0ubuntu9 provided by Ubuntu 20.04 for amd64.

(I think there are a few more bugs in there that do not result in a crash, but do result in a wrong return value. Should I include the details in here or report that separately?)
Comment 1 Andreas Schwab 2020-09-16 13:12:13 UTC
Fixed in 2.33.  For further bugs please open separate reports.
Comment 2 Florian Weimer 2020-11-11 12:38:35 UTC
Marking as security- because this needs a crafted pattern.