[Rpm-maint] [PATCH 5/5] Fix horrible bug in freeing macro arguments
Alexey Tourbin
alexey.tourbin at gmail.com
Tue Feb 5 04:31:39 UTC 2013
After a macro which takes options/arguments is called, such as %systemd_post,
freeArgs() frees ALL macros *previously defined in specfile*. For example,
in amanda.spec, after scriptlet sections which invoke %systemd_* macros are
processed, %amanda_user and %amanda_group in %files sections become undefined,
resulting in malformed owner/group file metadata.
$ rpm -qp --qf '[%{FILEUSERNAME}:%{FILEGROUPNAME}\n]' amanda-3.3.2-2.fc18.x86_64.rpm |
> sort | uniq -c | sort -n | tail
3 %amanda_user:%amanda_group
104 root:root
This change installs additional name check in freeArgs(), so that, upon
finishing macro call, only macro arguments are freed.
---
rpmio/macro.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/rpmio/macro.c b/rpmio/macro.c
index eee7716..d124b87 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -625,6 +625,9 @@ freeArgs(MacroBuf mb)
assert(me);
if (me->level < mb->depth)
continue;
+ int c = *me->name;
+ if (!(c == '*' || c == '#' || c == '-' || risdigit(c)))
+ continue;
if (strlen(me->name) == 1 && strchr("#*0", *me->name)) {
if (*me->name == '*' && me->used > 0)
skiptest = 1; /* XXX skip test for %# %* %0 */
--
1.8.1
More information about the Rpm-maint
mailing list