[Rpm-maint] [rpm-software-management/rpm] Sending multiple identical options to a macro will leak them to the next macro accepting the same option (Issue #3056)
Miro Hrončok
notifications at github.com
Tue Apr 23 13:37:31 UTC 2024
**Describe the bug**
Consider this situation:
Macros:
```
%macro_leaking(E:) %{nil}
%macro_infected(E:) echo -- "%{-E:-E was provided: %{-E*}}%{!-E:there was no -E}"
```
Notice both macros take an `-E` option with a value. The exact name of that option is not limited to `E`.
And run:
```
%macro_leaking -E myEoption1 -E myEoption2
%macro_infected
%macro_infected
%macro_infected
```
Results in:
```
echo -- "-E was provided: myEoption1"
echo -- "there was no -E"
echo -- "there was no -E"
```
See that the value passed to `-E` leaks to the infected macro. Moreover:
```
%macro_leaking -E myEoption1 -E myEoption2 -E myEoption3 -E myEoption4
%macro_infected
%macro_infected
%macro_infected
%macro_infected
```
Leads to:
```
echo -- "-E was provided: myEoption3"
echo -- "-E was provided: myEoption2"
echo -- "-E was provided: myEoption1"
echo -- "there was no -E"
```
The leaking and infected macros can even be the same:
```
%macro_infected -E myEoption1 -E myEoption2 -E myEoption3 -E myEoption4
%macro_infected
%macro_infected
%macro_infected
%macro_infected
```
Leads to:
```
echo -- "-E was provided: myEoption4"
echo -- "-E was provided: myEoption3"
echo -- "-E was provided: myEoption2"
echo -- "-E was provided: myEoption1"
echo -- "there was no -E"
```
**To Reproduce**
Spec:
```
Name: reproducer-eee
Version: 0
Release: 0
Summary: ...
License: ...
%description
...
%define macro_leaking(E:) %{nil}
%define macro_infected(E:) echo -- "%{-E:-E was provided: %{-E*}}%{!-E:there was no -E}"
%macro_leaking -E myEoption1 -E myEoption2
%macro_infected
%macro_infected
%macro_infected
```
Run `rpmspec -P reproducer-eee.spec`.
---
This impacts macros in Fedora. When I run:
```
%check
%pyproject_check_import -e '*django*' -e '*flask*' -e '*httpx*' -e '*requests*' -e '*sqla*' -e '*starlette*'
%tox
```
The `%tox` macro will receive one of the `-e` values (coincidentally, `%tox` also uses `-e` for one of its options).
**Expected behavior**
Passing option values multiple times should never leak to other macro calls.
**Environment**
- OS / Distribution: Fedora 39, 41
- Version rpm-4.19.1.1-1.fc39, rpm-4.19.1.1-1.fc40
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/3056
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/3056 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20240423/8d2d374d/attachment.html>
More information about the Rpm-maint
mailing list