Proper fix for comments affecting macro file parsing (#1953910)
This commit is contained in:
parent
e38cfd281b
commit
77dba0a29f
92
0001-Ignore-comment-line-contents-in-macro-files-1659.patch
Normal file
92
0001-Ignore-comment-line-contents-in-macro-files-1659.patch
Normal file
@ -0,0 +1,92 @@
|
||||
From 847c6f062c267c4be643be9c202141bd330a7891 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <847c6f062c267c4be643be9c202141bd330a7891.1619695949.git.pmatilai@redhat.com>
|
||||
From: Panu Matilainen <pmatilai@redhat.com>
|
||||
Date: Wed, 28 Apr 2021 10:20:55 +0300
|
||||
Subject: [PATCH] Ignore comment line contents in macro files (#1659)
|
||||
|
||||
Previously %{ and similar in macro file comment line would cause the
|
||||
line continuation logic to trigger and silently eat macro definitions
|
||||
up to the next empty line. Since 75275a87cff04da65d3557f2c40ea2b526528c4c
|
||||
we permit empty lines inside macro definitions, which would cause the
|
||||
whole remaining file to be silently skipped (RhBug:1953910)
|
||||
|
||||
Only ever parse macro file lines starting with %, and add a test for
|
||||
the case.
|
||||
|
||||
Actual patch by Michael Schroeder, testcase by undersigned.
|
||||
|
||||
Fixes: #1659
|
||||
---
|
||||
rpmio/macro.c | 8 ++++++++
|
||||
tests/data/macros.testfile | 7 +++++++
|
||||
tests/rpmmacro.at | 17 +++++++++++++++++
|
||||
3 files changed, 32 insertions(+)
|
||||
|
||||
diff --git a/rpmio/macro.c b/rpmio/macro.c
|
||||
index 6dfc73336..94ff5187d 100644
|
||||
--- a/rpmio/macro.c
|
||||
+++ b/rpmio/macro.c
|
||||
@@ -226,6 +226,14 @@ rdcl(char * buf, size_t size, FILE *f)
|
||||
nb--;
|
||||
if (*q == 0)
|
||||
break; /* no newline found, EOF */
|
||||
+ if (p == buf) {
|
||||
+ while (*p && isblank(*p))
|
||||
+ p++;
|
||||
+ if (*p != '%') { /* only parse actual macro */
|
||||
+ *q = '\0'; /* trim trailing \r, \n */
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
for (; p < q; p++) {
|
||||
switch (*p) {
|
||||
case '\\':
|
||||
diff --git a/tests/data/macros.testfile b/tests/data/macros.testfile
|
||||
index 86fd883fc..f56c80578 100644
|
||||
--- a/tests/data/macros.testfile
|
||||
+++ b/tests/data/macros.testfile
|
||||
@@ -5,6 +5,13 @@
|
||||
}
|
||||
%second %{?def:macro_2}
|
||||
|
||||
+# empty lines inside a %{ block
|
||||
+%empty0 %{expand:
|
||||
+some
|
||||
+
|
||||
+thing
|
||||
+}
|
||||
+
|
||||
%comment1 %{expand:
|
||||
read
|
||||
%dnl comment
|
||||
diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
|
||||
index 072b986be..c0f114087 100644
|
||||
--- a/tests/rpmmacro.at
|
||||
+++ b/tests/rpmmacro.at
|
||||
@@ -945,6 +945,23 @@ read
|
||||
[])
|
||||
AT_CLEANUP
|
||||
|
||||
+AT_SETUP([macro file empty lines])
|
||||
+AT_KEYWORDS([macros])
|
||||
+AT_CHECK([
|
||||
+runroot rpm \
|
||||
+ --macros /data/macros.testfile \
|
||||
+ --eval "%{empty0}"
|
||||
+],
|
||||
+[0],
|
||||
+[
|
||||
+some
|
||||
+
|
||||
+thing
|
||||
+
|
||||
+],
|
||||
+[])
|
||||
+AT_CLEANUP
|
||||
+
|
||||
AT_SETUP([macro traceback])
|
||||
AT_KEYWORDS([macros])
|
||||
AT_CHECK([
|
||||
--
|
||||
2.30.2
|
||||
|
@ -1,74 +0,0 @@
|
||||
From eb8aee3f45024fa1e631ac2da5b06f5a9abf16d3 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <eb8aee3f45024fa1e631ac2da5b06f5a9abf16d3.1619509954.git.pmatilai@redhat.com>
|
||||
From: Panu Matilainen <pmatilai@redhat.com>
|
||||
Date: Tue, 27 Apr 2021 10:51:14 +0300
|
||||
Subject: [PATCH] Revert "Fix logic error in macro file reader"
|
||||
|
||||
This trips over the following comment line in macros.python-srpm,
|
||||
preventing all subsequent macros from loading:
|
||||
|
||||
Temporarily revert to let Python builds continue while looking for
|
||||
proper fix.
|
||||
|
||||
This reverts commit 75275a87cff04da65d3557f2c40ea2b526528c4c.
|
||||
---
|
||||
rpmio/macro.c | 20 ++++++++++----------
|
||||
1 file changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/rpmio/macro.c b/rpmio/macro.c
|
||||
index 6dfc73336..f2a2335df 100644
|
||||
--- a/rpmio/macro.c
|
||||
+++ b/rpmio/macro.c
|
||||
@@ -209,24 +209,24 @@ findEntry(rpmMacroContext mc, const char *name, size_t namelen, size_t *pos)
|
||||
static int
|
||||
rdcl(char * buf, size_t size, FILE *f)
|
||||
{
|
||||
+ char *q = buf - 1; /* initialize just before buffer. */
|
||||
size_t nb = 0;
|
||||
+ size_t nread = 0;
|
||||
int pc = 0, bc = 0, xc = 0;
|
||||
int nlines = 0;
|
||||
char *p = buf;
|
||||
- char *q = buf;
|
||||
|
||||
if (f != NULL)
|
||||
do {
|
||||
- *q = '\0'; /* terminate */
|
||||
+ *(++q) = '\0'; /* terminate and move forward. */
|
||||
if (fgets(q, size, f) == NULL) /* read next line. */
|
||||
break;
|
||||
nlines++;
|
||||
nb = strlen(q);
|
||||
- for (q += nb; nb > 0 && iseol(q[-1]); q--)
|
||||
+ nread += nb; /* trim trailing \r and \n */
|
||||
+ for (q += nb - 1; nb > 0 && iseol(*q); q--)
|
||||
nb--;
|
||||
- if (*q == 0)
|
||||
- break; /* no newline found, EOF */
|
||||
- for (; p < q; p++) {
|
||||
+ for (; p <= q; p++) {
|
||||
switch (*p) {
|
||||
case '\\':
|
||||
switch (*(p+1)) {
|
||||
@@ -250,14 +250,14 @@ rdcl(char * buf, size_t size, FILE *f)
|
||||
case ']': if (xc > 0) xc--; break;
|
||||
}
|
||||
}
|
||||
- if ((nb == 0 || q[-1] != '\\') && !bc && !pc && !xc) {
|
||||
- *q = '\0'; /* trim trailing \r, \n */
|
||||
+ if (nb == 0 || (*q != '\\' && !bc && !pc && !xc) || *(q+1) == '\0') {
|
||||
+ *(++q) = '\0'; /* trim trailing \r, \n */
|
||||
break;
|
||||
}
|
||||
q++; nb++; /* copy newline too */
|
||||
size -= nb;
|
||||
- if (q[-1] == '\r') /* XXX avoid \r madness */
|
||||
- q[-1] = '\n';
|
||||
+ if (*q == '\r') /* XXX avoid \r madness */
|
||||
+ *q = '\n';
|
||||
} while (size > 0);
|
||||
return nlines;
|
||||
}
|
||||
--
|
||||
2.30.2
|
||||
|
8
rpm.spec
8
rpm.spec
@ -32,7 +32,7 @@
|
||||
|
||||
%global rpmver 4.16.90
|
||||
%global snapver git15395
|
||||
%global rel 4
|
||||
%global rel 5
|
||||
%global sover 9
|
||||
|
||||
%global srcver %{rpmver}%{?snapver:-%{snapver}}
|
||||
@ -54,8 +54,7 @@ Patch3: rpm-4.9.90-no-man-dirs.patch
|
||||
# https://github.com/rpm-software-management/rpm/pull/473
|
||||
Patch6: 0001-find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
|
||||
|
||||
# Temporarily for https://bugzilla.redhat.com/show_bug.cgi?id=1953910
|
||||
Patch10: 0001-Revert-Fix-logic-error-in-macro-file-reader.patch
|
||||
Patch10: 0001-Ignore-comment-line-contents-in-macro-files-1659.patch
|
||||
|
||||
# Patches already upstream:
|
||||
|
||||
@ -572,6 +571,9 @@ fi
|
||||
%doc doc/librpm/html/*
|
||||
|
||||
%changelog
|
||||
* Thu Apr 29 2021 Panu Matilainen <pmatilai@redhat.com> - 4.16.90-0.git15395.5
|
||||
- Proper fix for comments affecting macro file parsing (#1953910)
|
||||
|
||||
* Tue Apr 27 2021 Panu Matilainen <pmatilai@redhat.com> - 4.16.90-0.git15395.4
|
||||
- Enable fapolicyd plugin build
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user