fix upstream bugzilla 26620, 26637 and fix i686 tst-strftime3.c compile error.

This commit is contained in:
liqingqing_1229 2020-10-27 10:57:29 +08:00
parent 7d1788c8f7
commit acbe8dad98
4 changed files with 516 additions and 1 deletions

View File

@ -0,0 +1,104 @@
From a140ff9162f353e804d6a8c83c8f3c18511850dd Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 16 Sep 2020 12:41:14 +0200
Subject: [PATCH] Fix handling of collating symbols in fnmatch (bug 26620)
The variable idx contains the index into the extra array, whereas wextra
points into the extra array at this index, containing the length of the
following collating sequence in the wide character representation.
---
posix/Makefile | 3 ++-
posix/fnmatch_loop.c | 4 ++--
posix/tst-fnmatch6.c | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 3 deletions(-)
create mode 100644 posix/tst-fnmatch6.c
diff --git a/posix/Makefile b/posix/Makefile
index 605ddbade8..83c4d57231 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -96,7 +96,7 @@ tests := test-errno tstgetopt testfnm runtests runptests \
bug-getopt5 tst-getopt_long1 bug-regex34 bug-regex35 \
tst-pathconf tst-rxspencer-no-utf8 \
tst-fnmatch3 bug-regex36 \
- tst-fnmatch4 tst-fnmatch5 \
+ tst-fnmatch4 tst-fnmatch5 tst-fnmatch6 \
tst-posix_spawn-fd tst-posix_spawn-setsid \
tst-posix_fadvise tst-posix_fadvise64 \
tst-sysconf-empty-chroot tst-glob_symlinks tst-fexecve \
@@ -197,6 +197,7 @@ $(objpfx)bug-regex35.out: $(gen-locales)
$(objpfx)tst-fnmatch.out: $(gen-locales)
$(objpfx)tst-fnmatch4.out: $(gen-locales)
$(objpfx)tst-fnmatch5.out: $(gen-locales)
+$(objpfx)tst-fnmatch6.out: $(gen-locales)
$(objpfx)tst-regex.out: $(gen-locales)
$(objpfx)tst-regex2.out: $(gen-locales)
$(objpfx)tst-regexloc.out: $(gen-locales)
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index 8ead4dc7b9..0f890d4782 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -564,7 +564,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
/* Get the collation sequence value. */
is_seqval = 1;
# if WIDE_CHAR_VERSION
- cold = wextra[1 + wextra[idx]];
+ cold = wextra[1 + wextra[0]];
# else
idx += 1 + extra[idx];
/* Adjust for the alignment. */
@@ -738,7 +738,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
/* Get the collation sequence value. */
is_seqval = 1;
# if WIDE_CHAR_VERSION
- cend = wextra[1 + wextra[idx]];
+ cend = wextra[1 + wextra[0]];
# else
idx += 1 + extra[idx];
/* Adjust for the alignment. */
diff --git a/posix/tst-fnmatch6.c b/posix/tst-fnmatch6.c
new file mode 100644
index 0000000000..c255702a72
--- /dev/null
+++ b/posix/tst-fnmatch6.c
@@ -0,0 +1,37 @@
+/* Test for fnmatch handling of collating symbols (bug 26620)
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fnmatch.h>
+#include <locale.h>
+#include <support/check.h>
+#include <support/support.h>
+
+static int
+do_test (void)
+{
+ setlocale (LC_ALL, "en_US.UTF-8");
+ /* From iso14651_t1_common:
+ collating-element <U004C_00B7> from "<U004C><U00B7>"
+ % decomposition of LATIN CAPITAL LETTER L WITH MIDDLE DOT */
+ TEST_VERIFY (fnmatch ("[[.L\xc2\xb7.]]", ".", 0) != 0);
+ TEST_VERIFY (fnmatch ("[[.L\xc2\xb7.]]", "L\xc2\xb7", 0) == 0);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
--
2.23.0

View File

@ -0,0 +1,136 @@
From 6dd2dae7cfe2077c3af854a6220fe582b6bad999 Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Thu, 15 Oct 2020 16:31:04 +0800
Subject: [PATCH] Add Reiwa era tests to time/tst-strftime3.c Also fix printf
warning
---
time/tst-strftime3.c | 72 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/time/tst-strftime3.c b/time/tst-strftime3.c
index a4c427b3..0ec14869 100644
--- a/time/tst-strftime3.c
+++ b/time/tst-strftime3.c
@@ -1,5 +1,5 @@
/* Data-driven tests for strftime/strptime.
- Copyright (C) 2019 Free Software Foundation, Inc. This file is
+ Copyright (C) 2019-2020 Free Software Foundation, Inc. This file is
part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
@@ -25,6 +25,7 @@
#include <support/check.h>
#include <array_length.h>
+#include <libc-diag.h>
/* These exist for the convenience of writing the test data, because
zero-based vs one-based. */
@@ -291,6 +292,62 @@ const Data data[] = {
1990, Jan, 1, Mon, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
/* <U5E73><U6210>02<U5E74> 平成02年 */
"\xca\xbf\xc0\xae""02\xc7\xaf" },
+
+
+ { "Japanese era change, 2019, before transition year",
+ 2018, Dec, 31, Mon, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+ /* <U5E73><U6210>30<U5E74> 昭和30年 */
+ "\xe5\xb9\xb3\xe6\x88\x90""30\xe5\xb9\xb4" },
+ { "Japanese era change, 2019, start of transition year",
+ 2019, Jan, 1, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+ /* <U5E73><U6210>30<U5E74> 昭和31年 */
+ "\xe5\xb9\xb3\xe6\x88\x90""31\xe5\xb9\xb4" },
+
+ { "Japanese era change, 2019, before transition",
+ 2019, Apr, 30, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+ /* <U5E73><U6210>30<U5E74> 昭和31年 */
+ "\xe5\xb9\xb3\xe6\x88\x90""31\xe5\xb9\xb4" },
+ { "Japanese era change, 2019, after transition",
+ 2019, May, 1, Wed, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+ /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+ "\xe4\xbb\xa4\xe5\x92\x8c\xe5\x85\x83\xe5\xb9\xb4" },
+
+ { "Japanese era change, 2019, end of transition year",
+ 2019, Dec, 31, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+ /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+ "\xe4\xbb\xa4\xe5\x92\x8c\xe5\x85\x83\xe5\xb9\xb4" },
+ { "Japanese era change, 2019, after transition year",
+ 2020, Jan, 1, Wed, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+ /* <U4EE4><U548C>02<U5E74> 令和02年 */
+ "\xe4\xbb\xa4\xe5\x92\x8c""02\xe5\xb9\xb4" },
+
+
+ { "Japanese era change, 2019, before transition year",
+ 2018, Dec, 31, Mon, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+ /* <U5E73><U6210>30<U5E74> 昭和30年 */
+ "\xca\xbf\xc0\xae""30\xc7\xaf" },
+ { "Japanese era change, 2019, start of transition year",
+ 2019, Jan, 1, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+ /* <U5E73><U6210>30<U5E74> 昭和31年 */
+ "\xca\xbf\xc0\xae""31\xc7\xaf" },
+
+ { "Japanese era change, 2019, before transition",
+ 2019, Apr, 30, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+ /* <U5E73><U6210>30<U5E74> 昭和31年 */
+ "\xca\xbf\xc0\xae""31\xc7\xaf" },
+ { "Japanese era change, 2019, after transition",
+ 2019, May, 1, Wed, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+ /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+ "\xce\xe1\xcf\xc2\xb8\xb5\xc7\xaf" },
+
+ { "Japanese era change, 2019, end of transition year",
+ 2019, Dec, 31, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+ /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+ "\xce\xe1\xcf\xc2\xb8\xb5\xc7\xaf" },
+ { "Japanese era change, 2019, after transition year",
+ 2020, Jan, 1, Wed, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+ /* <U4EE4><U548C>02<U5E74> 令和02年 */
+ "\xce\xe1\xcf\xc2""02\xc7\xaf" },
};
#define NDATA array_length(data)
@@ -348,7 +405,7 @@ print_string_hex (const char *header, const char *str)
if (' ' <= w[i] && w[i] <= '~')
putchar (w[i]);
else
- printf ("<U%04X>", w[i]);
+ printf ("<U%04X>", (int) w[i]);
}
printf ("\n");
}
@@ -384,6 +441,14 @@ tm_to_printed (struct tm *tm, char *buffer)
sprintf (temp, "%d", tm->tm_wday);
}
+ DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (9, 0)
+ /* GCC 9 warns that strncmp may truncate its output, but that's why
+ we're using it. When it needs to truncate, it got corrupted
+ data, and we only care that the string is different than valid
+ data, which won't truncate. */
+ DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-truncation=");
+#endif
snprintf (buffer, TMBUFLEN, "%04d/%02d/%02d %02d:%02d:%02d %s",
tm->tm_year + 1900,
tm->tm_mon + 1,
@@ -392,6 +457,7 @@ tm_to_printed (struct tm *tm, char *buffer)
tm->tm_min,
tm->tm_sec,
wn);
+ DIAG_POP_NEEDS_COMMENT;
}
static int
--
2.23.0

View File

@ -0,0 +1,265 @@
From 574500a108be1d2a6a0dc97a075c9e0a98371aba Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Tue, 29 Sep 2020 14:10:20 -0300
Subject: [PATCH] sysvipc: Fix SEM_STAT_ANY kernel argument pass [BZ #26637]
Handle SEM_STAT_ANY the same way as SEM_STAT so that the buffer argument
of SEM_STAT_ANY is properly passed to the kernel and back.
The regression testcase checks for Linux specifix SysV ipc message
control extension. For IPC_INFO/SEM_INFO it tries to match the values
against the tunable /proc values and for SEM_STAT/SEM_STAT_ANY it
check if the create message queue is within the global list returned
by the kernel.
Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on
Linux v4.15).
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/semctl.c | 2 +
sysdeps/unix/sysv/linux/tst-sysvsem-linux.c | 184 ++++++++++++++++++++
sysvipc/test-sysvsem.c | 1 +
4 files changed, 189 insertions(+), 1 deletion(-)
create mode 100644 sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 773aaea0..d8cd107d 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -45,7 +45,8 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \
- tst-rlimit-infinity tst-ofdlocks
+ tst-rlimit-infinity tst-ofdlocks \
+ tst-sysvsem-linux
tests-internal += tst-ofdlocks-compat
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index e2925447..bdf31ca7 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -51,6 +51,7 @@ __new_semctl (int semid, int semnum, int cmd, ...)
case IPC_STAT: /* arg.buf */
case IPC_SET:
case SEM_STAT:
+ case SEM_STAT_ANY:
case IPC_INFO: /* arg.__buf */
case SEM_INFO:
va_start (ap, cmd);
@@ -90,6 +91,7 @@ __old_semctl (int semid, int semnum, int cmd, ...)
case IPC_STAT: /* arg.buf */
case IPC_SET:
case SEM_STAT:
+ case SEM_STAT_ANY:
case IPC_INFO: /* arg.__buf */
case SEM_INFO:
va_start (ap, cmd);
diff --git a/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
new file mode 100644
index 00000000..45f19e2d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
@@ -0,0 +1,184 @@
+/* Basic tests for Linux SYSV semaphore extensions.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <support/check.h>
+#include <support/temp_file.h>
+
+/* These are for the temporary file we generate. */
+static char *name;
+static int semid;
+
+static void
+remove_sem (void)
+{
+ /* Enforce message queue removal in case of early test failure.
+ Ignore error since the sem may already have being removed. */
+ semctl (semid, 0, IPC_RMID, 0);
+}
+
+static void
+do_prepare (int argc, char *argv[])
+{
+ TEST_VERIFY_EXIT (create_temp_file ("tst-sysvsem.", &name) != -1);
+}
+
+#define PREPARE do_prepare
+
+#define SEM_MODE 0644
+
+union semun
+{
+ int val;
+ struct semid_ds *buf;
+ unsigned short *array;
+ struct seminfo *__buf;
+};
+
+struct test_seminfo
+{
+ int semmsl;
+ int semmns;
+ int semopm;
+ int semmni;
+};
+
+/* It tries to obtain some system-wide SysV semaphore information from /proc
+ to check against IPC_INFO/SEM_INFO. The /proc only returns the tunables
+ value of SEMMSL, SEMMNS, SEMOPM, and SEMMNI.
+
+ The kernel also returns constant value for SEMVMX, SEMMNU, SEMMAP, SEMUME,
+ and also SEMUSZ and SEMAEM (for IPC_INFO). The issue to check them is they
+ might change over kernel releases. */
+
+static void
+read_sem_stat (struct test_seminfo *tseminfo)
+{
+ FILE *f = fopen ("/proc/sys/kernel/sem", "r");
+ if (f == NULL)
+ FAIL_UNSUPPORTED ("/proc is not mounted or /proc/sys/kernel/sem is not "
+ "available");
+
+ int r = fscanf (f, "%d %d %d %d",
+ &tseminfo->semmsl, &tseminfo->semmns, &tseminfo->semopm,
+ &tseminfo->semmni);
+ TEST_VERIFY_EXIT (r == 4);
+
+ fclose (f);
+}
+
+
+/* Check if the semaphore with IDX (index into the kernel's internal array)
+ matches the one with KEY. The CMD is either SEM_STAT or SEM_STAT_ANY. */
+
+static bool
+check_seminfo (int idx, key_t key, int cmd)
+{
+ struct semid_ds seminfo;
+ int sid = semctl (idx, 0, cmd, (union semun) { .buf = &seminfo });
+ /* Ignore unused array slot returned by the kernel or information from
+ unknown semaphores. */
+ if ((sid == -1 && errno == EINVAL) || sid != semid)
+ return false;
+
+ if (sid == -1)
+ FAIL_EXIT1 ("semctl with SEM_STAT failed (errno=%d)", errno);
+
+ TEST_COMPARE (seminfo.sem_perm.__key, key);
+ TEST_COMPARE (seminfo.sem_perm.mode, SEM_MODE);
+ TEST_COMPARE (seminfo.sem_nsems, 1);
+
+ return true;
+}
+
+static int
+do_test (void)
+{
+ atexit (remove_sem);
+
+ key_t key = ftok (name, 'G');
+ if (key == -1)
+ FAIL_EXIT1 ("ftok failed: %m");
+
+ semid = semget (key, 1, IPC_CREAT | IPC_EXCL | SEM_MODE);
+ if (semid == -1)
+ FAIL_EXIT1 ("semget failed: %m");
+
+ struct test_seminfo tipcinfo;
+ read_sem_stat (&tipcinfo);
+
+ int semidx;
+
+ {
+ struct seminfo ipcinfo;
+ semidx = semctl (semid, 0, IPC_INFO, (union semun) { .__buf = &ipcinfo });
+ if (semidx == -1)
+ FAIL_EXIT1 ("semctl with IPC_INFO failed: %m");
+
+ TEST_COMPARE (ipcinfo.semmsl, tipcinfo.semmsl);
+ TEST_COMPARE (ipcinfo.semmns, tipcinfo.semmns);
+ TEST_COMPARE (ipcinfo.semopm, tipcinfo.semopm);
+ TEST_COMPARE (ipcinfo.semmni, tipcinfo.semmni);
+ }
+
+ /* Same as before but with SEM_INFO. */
+ {
+ struct seminfo ipcinfo;
+ semidx = semctl (semid, 0, SEM_INFO, (union semun) { .__buf = &ipcinfo });
+ if (semidx == -1)
+ FAIL_EXIT1 ("semctl with IPC_INFO failed: %m");
+
+ TEST_COMPARE (ipcinfo.semmsl, tipcinfo.semmsl);
+ TEST_COMPARE (ipcinfo.semmns, tipcinfo.semmns);
+ TEST_COMPARE (ipcinfo.semopm, tipcinfo.semopm);
+ TEST_COMPARE (ipcinfo.semmni, tipcinfo.semmni);
+ }
+
+ /* We check if the created semaphore shows in the system-wide status. */
+ bool found = false;
+ for (int i = 0; i <= semidx; i++)
+ {
+ /* We can't tell apart if SEM_STAT_ANY is not supported (kernel older
+ than 4.17) or if the index used is invalid. So it just check if
+ value returned from a valid call matches the created semaphore. */
+ check_seminfo (i, key, SEM_STAT_ANY);
+
+ if (check_seminfo (i, key, SEM_STAT))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ FAIL_EXIT1 ("semctl with SEM_STAT/SEM_STAT_ANY could not find the "
+ "created semaphore");
+
+ if (semctl (semid, 0, IPC_RMID, 0) == -1)
+ FAIL_EXIT1 ("semctl failed: %m");
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysvipc/test-sysvsem.c b/sysvipc/test-sysvsem.c
index a8e9bff0..d1977729 100644
--- a/sysvipc/test-sysvsem.c
+++ b/sysvipc/test-sysvsem.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <stdbool.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
--
2.23.0

View File

@ -59,7 +59,7 @@
##############################################################################
Name: glibc
Version: 2.28
Release: 45
Release: 46
Summary: The GNU libc libraries
License: %{all_license}
URL: http://www.gnu.org/software/glibc/
@ -93,6 +93,9 @@ Patch16: Fix-CVE-2020-6096-002.patch
Patch17: backport-Correct-locking-and-cancellation-cleanup-in-syslog-functions.patch
Patch18: makedb-fix-build-with-libselinux-3.1.patch
Patch19: Workaround-deprecation-warnings-introduced-in-libselinux-3.1.patch
Patch20: backport-0001-Fix-handling-of-collating-symbols-in-fnmatch-bug-266.patch
Patch21: backport-sysvipc-Fix-SEM_STAT_ANY-kernel-argument-pass-BZ-26637.patch
Patch22: backport-i686-tst-strftime3-fix-printf-warning.patch
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
@ -1088,6 +1091,13 @@ fi
%doc hesiod/README.hesiod
%changelog
* Tue Oct 27 2020 Qingqing Li <liqingqing3@huawei.com> - 2.28-46
- fix handling of collating symbols in fnmatch.
upstream link is: https://sourceware.org/bugzilla/show_bug.cgi?id=26620
- fix SEM_STAT_ANY kernel argument pass.
upstream link is: https://sourceware.org/bugzilla/show_bug.cgi?26637
- fix i686 test-strftime3.c compile warning.
* Tue Sep 22 2020 zhaowei<zhaowei23@huawei.com> - 2.28-45
- fix bug 965941: fix build with libselinux >= 3.1
- origin bugzilla link is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=965941