bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fnmatch: Override fnmatch from glibc versions < 2.22


From: Bruno Haible
Subject: fnmatch: Override fnmatch from glibc versions < 2.22
Date: Wed, 16 Aug 2023 22:03:24 +0200

The fnmatch() unit tests currently
  - succeed on glibc versions >= 2.22 (here REPLACE_FNMATCH=0 and the glibc
    fnmatch() is good enough),
  - succeed on glibc versions < 2.13 (thanks to REPLACE_FNMATCH=1).

But for the versions in-between the behaviour is inconsistent: I see
test-fnmatch-[12].sh
  - fail on Slackware 13.37 (glibc 2.13),
  - fail on openSUSE 12.1 (glibc 2.14.1),
  - fail on Slackware 14 (glibc 2.15),
  - succeed on CentOS 7 (glibc 2.17).
On all these systems we have REPLACE_FNMATCH=0.

The failure occurs at test-fnmatch.c:343:
  ASSERT (fnmatch ("[[:alpha:]'[:alpha:]\0]", "a", 0) == FNM_NOMATCH);

This test comes from glibc, and was added added as a response to the
glibc bugs
  https://sourceware.org/bugzilla/show_bug.cgi?id=17062
  https://sourceware.org/bugzilla/show_bug.cgi?id=18032
  https://sourceware.org/bugzilla/show_bug.cgi?id=18036
These bugs are buffer overflows that may make programs crash. Therefore IMO
it makes sense if Gnulib protects the programs against these bugs. These bugs
were fixed in glibc 2.22. Therefore a gnulib change here does not affect
recent distros.

Another glibc bug
  https://sourceware.org/bugzilla/show_bug.cgi?id=14185
is not so critical; IMO we can live without its fix, especially since it was
only fixed in glibc 2.34.

A proper Autoconf test for these three bugs would take some time to write. I'm
choosing the quick approach to just test for the glibc version.


2023-08-16  Bruno Haible  <bruno@clisp.org>

        fnmatch: Override fnmatch from glibc versions < 2.22.
        * m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Force REPLACE_FNMATCH=1 in
        glibc versions < 2.22.

diff --git a/m4/fnmatch.m4 b/m4/fnmatch.m4
index e99737a476..85e3605c76 100644
--- a/m4/fnmatch.m4
+++ b/m4/fnmatch.m4
@@ -1,4 +1,4 @@
-# Check for fnmatch - serial 19  -*- coding: utf-8 -*-
+# Check for fnmatch - serial 20  -*- coding: utf-8 -*-
 
 # Copyright (C) 2000-2007, 2009-2023 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -108,6 +108,17 @@ AC_DEFUN([gl_FUNC_FNMATCH_POSIX]
                  exists in glibc 2.12, fixed in glibc 2.13.  */
               if (!y ("[/b", "[/b", 0)) /*"]]"*/
                 result |= 4;
+              /* glibc bug 
<https://sourceware.org/bugzilla/show_bug.cgi?id=17062>
+                 is fixed in glibc 2.20.
+                 glibc bugs 
<https://sourceware.org/bugzilla/show_bug.cgi?id=18032>
+                            
<https://sourceware.org/bugzilla/show_bug.cgi?id=18036>
+                 are fixed in glibc 2.22.
+                 These bugs are not easy to test for reliably (without mmap),
+                 therefore test the glibc version.  */
+              #if defined __GLIBC__
+              if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 22)
+                result |= 4;
+              #endif
               /* This test fails on FreeBSD 13.2, NetBSD 9.3, Cygwin 3.4.6.  */
               if (!y ("[[:alnum:]]", "a", 0))
                 result |= 8;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]