|
Panu Matilainen |
77dba0 |
From 847c6f062c267c4be643be9c202141bd330a7891 Mon Sep 17 00:00:00 2001
|
|
Panu Matilainen |
77dba0 |
Message-Id: <847c6f062c267c4be643be9c202141bd330a7891.1619695949.git.pmatilai@redhat.com>
|
|
Panu Matilainen |
77dba0 |
From: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
77dba0 |
Date: Wed, 28 Apr 2021 10:20:55 +0300
|
|
Panu Matilainen |
77dba0 |
Subject: [PATCH] Ignore comment line contents in macro files (#1659)
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
Previously %{ and similar in macro file comment line would cause the
|
|
Panu Matilainen |
77dba0 |
line continuation logic to trigger and silently eat macro definitions
|
|
Panu Matilainen |
77dba0 |
up to the next empty line. Since 75275a87cff04da65d3557f2c40ea2b526528c4c
|
|
Panu Matilainen |
77dba0 |
we permit empty lines inside macro definitions, which would cause the
|
|
Panu Matilainen |
77dba0 |
whole remaining file to be silently skipped (RhBug:1953910)
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
Only ever parse macro file lines starting with %, and add a test for
|
|
Panu Matilainen |
77dba0 |
the case.
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
Actual patch by Michael Schroeder, testcase by undersigned.
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
Fixes: #1659
|
|
Panu Matilainen |
77dba0 |
---
|
|
Panu Matilainen |
77dba0 |
rpmio/macro.c | 8 ++++++++
|
|
Panu Matilainen |
77dba0 |
tests/data/macros.testfile | 7 +++++++
|
|
Panu Matilainen |
77dba0 |
tests/rpmmacro.at | 17 +++++++++++++++++
|
|
Panu Matilainen |
77dba0 |
3 files changed, 32 insertions(+)
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
diff --git a/rpmio/macro.c b/rpmio/macro.c
|
|
Panu Matilainen |
77dba0 |
index 6dfc73336..94ff5187d 100644
|
|
Panu Matilainen |
77dba0 |
--- a/rpmio/macro.c
|
|
Panu Matilainen |
77dba0 |
+++ b/rpmio/macro.c
|
|
Panu Matilainen |
77dba0 |
@@ -226,6 +226,14 @@ rdcl(char * buf, size_t size, FILE *f)
|
|
Panu Matilainen |
77dba0 |
nb--;
|
|
Panu Matilainen |
77dba0 |
if (*q == 0)
|
|
Panu Matilainen |
77dba0 |
break; /* no newline found, EOF */
|
|
Panu Matilainen |
77dba0 |
+ if (p == buf) {
|
|
Panu Matilainen |
77dba0 |
+ while (*p && isblank(*p))
|
|
Panu Matilainen |
77dba0 |
+ p++;
|
|
Panu Matilainen |
77dba0 |
+ if (*p != '%') { /* only parse actual macro */
|
|
Panu Matilainen |
77dba0 |
+ *q = '\0'; /* trim trailing \r, \n */
|
|
Panu Matilainen |
77dba0 |
+ break;
|
|
Panu Matilainen |
77dba0 |
+ }
|
|
Panu Matilainen |
77dba0 |
+ }
|
|
Panu Matilainen |
77dba0 |
for (; p < q; p++) {
|
|
Panu Matilainen |
77dba0 |
switch (*p) {
|
|
Panu Matilainen |
77dba0 |
case '\\':
|
|
Panu Matilainen |
77dba0 |
diff --git a/tests/data/macros.testfile b/tests/data/macros.testfile
|
|
Panu Matilainen |
77dba0 |
index 86fd883fc..f56c80578 100644
|
|
Panu Matilainen |
77dba0 |
--- a/tests/data/macros.testfile
|
|
Panu Matilainen |
77dba0 |
+++ b/tests/data/macros.testfile
|
|
Panu Matilainen |
77dba0 |
@@ -5,6 +5,13 @@
|
|
Panu Matilainen |
77dba0 |
}
|
|
Panu Matilainen |
77dba0 |
%second %{?def:macro_2}
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
+# empty lines inside a %{ block
|
|
Panu Matilainen |
77dba0 |
+%empty0 %{expand:
|
|
Panu Matilainen |
77dba0 |
+some
|
|
Panu Matilainen |
77dba0 |
+
|
|
Panu Matilainen |
77dba0 |
+thing
|
|
Panu Matilainen |
77dba0 |
+}
|
|
Panu Matilainen |
77dba0 |
+
|
|
Panu Matilainen |
77dba0 |
%comment1 %{expand:
|
|
Panu Matilainen |
77dba0 |
read
|
|
Panu Matilainen |
77dba0 |
%dnl comment
|
|
Panu Matilainen |
77dba0 |
diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
|
|
Panu Matilainen |
77dba0 |
index 072b986be..c0f114087 100644
|
|
Panu Matilainen |
77dba0 |
--- a/tests/rpmmacro.at
|
|
Panu Matilainen |
77dba0 |
+++ b/tests/rpmmacro.at
|
|
Panu Matilainen |
77dba0 |
@@ -945,6 +945,23 @@ read
|
|
Panu Matilainen |
77dba0 |
[])
|
|
Panu Matilainen |
77dba0 |
AT_CLEANUP
|
|
Panu Matilainen |
77dba0 |
|
|
Panu Matilainen |
77dba0 |
+AT_SETUP([macro file empty lines])
|
|
Panu Matilainen |
77dba0 |
+AT_KEYWORDS([macros])
|
|
Panu Matilainen |
77dba0 |
+AT_CHECK([
|
|
Panu Matilainen |
77dba0 |
+runroot rpm \
|
|
Panu Matilainen |
77dba0 |
+ --macros /data/macros.testfile \
|
|
Panu Matilainen |
77dba0 |
+ --eval "%{empty0}"
|
|
Panu Matilainen |
77dba0 |
+],
|
|
Panu Matilainen |
77dba0 |
+[0],
|
|
Panu Matilainen |
77dba0 |
+[
|
|
Panu Matilainen |
77dba0 |
+some
|
|
Panu Matilainen |
77dba0 |
+
|
|
Panu Matilainen |
77dba0 |
+thing
|
|
Panu Matilainen |
77dba0 |
+
|
|
Panu Matilainen |
77dba0 |
+],
|
|
Panu Matilainen |
77dba0 |
+[])
|
|
Panu Matilainen |
77dba0 |
+AT_CLEANUP
|
|
Panu Matilainen |
77dba0 |
+
|
|
Panu Matilainen |
77dba0 |
AT_SETUP([macro traceback])
|
|
Panu Matilainen |
77dba0 |
AT_KEYWORDS([macros])
|
|
Panu Matilainen |
77dba0 |
AT_CHECK([
|
|
Panu Matilainen |
77dba0 |
--
|
|
Panu Matilainen |
77dba0 |
2.30.2
|
|
Panu Matilainen |
77dba0 |
|