-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending multiple identical options to a macro will leak them to the next macro accepting the same option #3056
Comments
Yes, it's because the engine pushes the macro with each option but only pops it once. But see also #2449 that asks of a saner handling of multiple identical option. |
Saner handling of multiple identical options would be nice, but even without that, the described behavior is wrong. Agreed? |
It's a bug alright. I actually just stumbled on that code a couple of days ago thinking this doesn't look right. It isn't. The bug is as old as the macro engine itself, close to 26 years 😆 It's not just multiple identical options, it's any local macro multiply defined, issue being that freeArgs() only ever pops once. Easily reproduced with eg
It should "obviously" output 0. |
freeArgs() only popped any local macros once, so if a local macro was pushed multiple times, whether through %define or multiple identical options getting passed, we leaked any remaining macros to the outside scope. Simply pop the local macros in a loop to fix. Have the internal popMacro() return the previous pointer (if any) to simplify the job. We even had an expected-fail test for this, which now passes. This bug was circa 26 years old. Some might call it vintage at this point. Fixes: rpm-software-management#3056
freeArgs() only popped any local macros once, so if a local macro was pushed multiple times, whether through %define or multiple identical options getting passed, we leaked any remaining macros to the outside scope. Simply pop the local macros in a loop to fix. Have the internal popMacro() return the previous pointer (if any) to simplify the job. We even had an expected-fail test for this, now passing, but add a more straightforward reproducer too. This bug was circa 26 years old. Some might call it vintage at this point. Fixes: rpm-software-management#3056
freeArgs() only popped any local macros once, so if a local macro was pushed multiple times, whether through %define or multiple identical options getting passed, we leaked any remaining macros to the outside scope. Simply pop the local macros in a loop to fix. Have the internal popMacro() return the previous pointer (if any) to simplify the job. We even had an expected-fail test for this, now passing, but add a more straightforward reproducer too. This bug was circa 26 years old. Some might call it vintage at this point. Fixes: #3056
Oh and thanks for reporting! Like the testcase shows, we kinda knew about this all along but had forgotten, and who knows how long more this might've lurked along 😄 |
Is there anything I need to do to initiate a backport to 4.19.x? |
No, we'll cherry-pick obvious fixes when doing the next release. |
freeArgs() only popped any local macros once, so if a local macro was pushed multiple times, whether through %define or multiple identical options getting passed, we leaked any remaining macros to the outside scope. Simply pop the local macros in a loop to fix. Have the internal popMacro() return the previous pointer (if any) to simplify the job. We even had an expected-fail test for this, now passing, but add a more straightforward reproducer too. This bug was circa 26 years old. Some might call it vintage at this point. Fixes: rpm-software-management#3056 (cherry picked from commit 695b5c2)
freeArgs() only popped any local macros once, so if a local macro was pushed multiple times, whether through %define or multiple identical options getting passed, we leaked any remaining macros to the outside scope. Simply pop the local macros in a loop to fix. Have the internal popMacro() return the previous pointer (if any) to simplify the job. We even had an expected-fail test for this, now passing, but add a more straightforward reproducer too. This bug was circa 26 years old. Some might call it vintage at this point. Fixes: #3056 (cherry picked from commit 695b5c2)
Describe the bug
Consider this situation:
Macros:
Notice both macros take an
-E
option with a value. The exact name of that option is not limited toE
.And run:
Results in:
See that the value passed to
-E
leaks to the infected macro. Moreover:Leads to:
The leaking and infected macros can even be the same:
Leads to:
To Reproduce
Spec:
Run
rpmspec -P reproducer-eee.spec
.This impacts macros in Fedora. When I run:
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
The text was updated successfully, but these errors were encountered: