Bug 1185118 - %attr rule with missing closing paren causes inscrutable error messages
Summary: %attr rule with missing closing paren causes inscrutable error messages
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Jeff Mahoney
QA Contact: E-mail List
URL: https://github.com/rpm-software-manag...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-21 20:50 UTC by Jeff Mahoney
Modified: 2021-09-07 19:32 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
[PATCH] Handle missing closing paren in %attr rules (1.30 KB, patch)
2021-04-21 20:52 UTC, Jeff Mahoney
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Mahoney 2021-04-21 20:50:43 UTC
When a malformed rule such as:

%dir %attr(-,root,root /path/to/file

is encountered, rpmbuild fails with an error message like:

error: File must begin with "/": nÔLó_;^?

This is due to the check for the closing paren as found in other rule handlers is missing. When the rule is overwritten by spaces, parseForAttr assumes that the final character is the closing paren and will overwrite the entire string including the NUL terminator. Later, since the entire string is spaces and also not NUL terminated, the error message will include whatever garbage happens to be after the end of the string.

Reported upstream as https://github.com/rpm-software-management/rpm/issues/1648
Comment 1 Jeff Mahoney 2021-04-21 20:52:31 UTC
Created attachment 848632 [details]
[PATCH] Handle missing closing paren in %attr rules

parseForAttr is missing the check for the closing paren.  When a malformed
rule is encountered, the bounds for the end of the rule will be the NUL
terminator for the string.  When it overwrites the rule with spaces,
the entire string, including the NUL terminator, will be overwritten.

Later, in parseForSimple, the string will no longer contain a pathname and
will fail the check for files beginning with /.  Since the string is also
no longer NUL terminated, the error will contain garbage like the following:

error: File must begin with "/": nÔLó_;^?

Adding the check for the closing paren fixes the issue.

Fixes: #1648
Comment 2 Michael Schröder 2021-04-22 08:57:35 UTC
(Opening an issue in the upstream tracker is enough, you do not need to duplicate things into our bugzilla.)
Comment 3 Jeff Mahoney 2021-09-07 19:32:56 UTC
Fix has landed in upstream rpm 4.17 but not Tumbleweed yet.