Accepting request 964197 from home:dirkmueller:Factory
- add file-5.41-cache-regexps-locale-restore.patch to restore previous locale handling behavior OBS-URL: https://build.opensuse.org/request/show/964197 OBS-URL: https://build.opensuse.org/package/show/Base:System/file?expand=0&rev=238
This commit is contained in:
parent
97ba010f1a
commit
7f56c39f55
101
file-5.41-cache-regexps-locale-restore.patch
Normal file
101
file-5.41-cache-regexps-locale-restore.patch
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
From c25329eabeaba048cb6ef1448d1ee040c62c415f Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Dirk=20M=C3=BCller?= <dirk@dmllr.de>
|
||||||
|
Date: Tue, 22 Mar 2022 22:28:14 +0100
|
||||||
|
Subject: [PATCH] Restore locale handling after regex caching
|
||||||
|
|
||||||
|
file_regcomp/file_regfree had the side effect of setting and restoring
|
||||||
|
locale C_TYPE to C to have predictable regex matching. With regcomp
|
||||||
|
caching file_regfree has been changed to be only called at destruction
|
||||||
|
time, which means the library changed the locale setting for anything
|
||||||
|
else as well. Restore old behavior by splitting save/restore into
|
||||||
|
separate functions which are surrounding regcomp() and regexec() only.
|
||||||
|
---
|
||||||
|
src/funcs.c | 39 ++++++++++++++++++++++++++++++++-------
|
||||||
|
1 file changed, 32 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/funcs.c b/src/funcs.c
|
||||||
|
index dcfd352d..7ecaff33 100644
|
||||||
|
--- a/src/funcs.c
|
||||||
|
+++ b/src/funcs.c
|
||||||
|
@@ -658,35 +658,62 @@ out:
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+file_reg_set_ctype(file_regex_t *rx)
|
||||||
|
+{
|
||||||
|
+#ifdef USE_C_LOCALE
|
||||||
|
+ rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
|
||||||
|
+ assert(rx->old_lc_ctype != NULL);
|
||||||
|
+#else
|
||||||
|
+ (void)setlocale(LC_CTYPE, "C");
|
||||||
|
+#endif
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+file_reg_restore_ctype(file_regex_t *rx)
|
||||||
|
+{
|
||||||
|
+#ifdef USE_C_LOCALE
|
||||||
|
+ (void)uselocale(rx->old_lc_ctype);
|
||||||
|
+#else
|
||||||
|
+ (void)setlocale(LC_CTYPE, rx->old_lc_ctype);
|
||||||
|
+#endif
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
protected int
|
||||||
|
file_regcomp(file_regex_t *rx, const char *pat, int flags)
|
||||||
|
{
|
||||||
|
#ifdef USE_C_LOCALE
|
||||||
|
rx->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
|
||||||
|
assert(rx->c_lc_ctype != NULL);
|
||||||
|
- rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
|
||||||
|
- assert(rx->old_lc_ctype != NULL);
|
||||||
|
#else
|
||||||
|
rx->old_lc_ctype = setlocale(LC_CTYPE, NULL);
|
||||||
|
assert(rx->old_lc_ctype != NULL);
|
||||||
|
rx->old_lc_ctype = strdup(rx->old_lc_ctype);
|
||||||
|
assert(rx->old_lc_ctype != NULL);
|
||||||
|
- (void)setlocale(LC_CTYPE, "C");
|
||||||
|
#endif
|
||||||
|
rx->pat = pat;
|
||||||
|
|
||||||
|
- return rx->rc = regcomp(&rx->rx, pat, flags);
|
||||||
|
+ file_reg_set_ctype(rx);
|
||||||
|
+ rx->rc = regcomp(&rx->rx, pat, flags);
|
||||||
|
+ file_reg_restore_ctype(rx);
|
||||||
|
+
|
||||||
|
+ return rx->rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int
|
||||||
|
file_regexec(file_regex_t *rx, const char *str, size_t nmatch,
|
||||||
|
regmatch_t* pmatch, int eflags)
|
||||||
|
{
|
||||||
|
+ int rc;
|
||||||
|
assert(rx->rc == 0);
|
||||||
|
/* XXX: force initialization because glibc does not always do this */
|
||||||
|
if (nmatch != 0)
|
||||||
|
memset(pmatch, 0, nmatch * sizeof(*pmatch));
|
||||||
|
- return regexec(&rx->rx, str, nmatch, pmatch, eflags);
|
||||||
|
+ file_reg_set_ctype(rx);
|
||||||
|
+ rc = regexec(&rx->rx, str, nmatch, pmatch, eflags);
|
||||||
|
+ file_reg_restore_ctype(rx);
|
||||||
|
+
|
||||||
|
+ return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void
|
||||||
|
@@ -695,10 +722,8 @@ file_regfree(file_regex_t *rx)
|
||||||
|
if (rx->rc == 0)
|
||||||
|
regfree(&rx->rx);
|
||||||
|
#ifdef USE_C_LOCALE
|
||||||
|
- (void)uselocale(rx->old_lc_ctype);
|
||||||
|
freelocale(rx->c_lc_ctype);
|
||||||
|
#else
|
||||||
|
- (void)setlocale(LC_CTYPE, rx->old_lc_ctype);
|
||||||
|
free(rx->old_lc_ctype);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Mar 23 09:02:37 UTC 2022 - Dirk Müller <dmueller@suse.com>
|
||||||
|
|
||||||
|
- add file-5.41-cache-regexps-locale-restore.patch to restore
|
||||||
|
previous locale handling behavior
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Sat Mar 19 18:00:32 UTC 2022 - Dirk Müller <dmueller@suse.com>
|
Sat Mar 19 18:00:32 UTC 2022 - Dirk Müller <dmueller@suse.com>
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ Patch34: file-5.23-endian.patch
|
|||||||
Patch37: file-secure_getenv.patch
|
Patch37: file-secure_getenv.patch
|
||||||
Patch38: file-5.41-cache-regexps.patch
|
Patch38: file-5.41-cache-regexps.patch
|
||||||
Patch39: file-5.28-btrfs-image.dif
|
Patch39: file-5.28-btrfs-image.dif
|
||||||
|
Patch40: file-5.41-cache-regexps-locale-restore.patch
|
||||||
# Upstream commits as patches
|
# Upstream commits as patches
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
%global _sysconfdir /etc
|
%global _sysconfdir /etc
|
||||||
@ -128,6 +129,7 @@ to develop applications that require the magic "file" interface.
|
|||||||
%patch37 -p1 -b .getenv
|
%patch37 -p1 -b .getenv
|
||||||
%patch38 -p1 -b .regexp
|
%patch38 -p1 -b .regexp
|
||||||
%patch39 -p1 -b .btrfs
|
%patch39 -p1 -b .btrfs
|
||||||
|
%patch40 -p1 -b .locale
|
||||||
%patch -b .0
|
%patch -b .0
|
||||||
test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in
|
test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in
|
||||||
rm -fv src/magic.h
|
rm -fv src/magic.h
|
||||||
|
Loading…
Reference in New Issue
Block a user