Skip to content
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

%attr rule with missing closing paren causes inscrutable error messages #1648

Closed
jeffmahoney opened this issue Apr 21, 2021 · 0 comments · Fixed by #1649
Closed

%attr rule with missing closing paren causes inscrutable error messages #1648

jeffmahoney opened this issue Apr 21, 2021 · 0 comments · Fixed by #1649

Comments

@jeffmahoney
Copy link
Contributor

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.

jeffmahoney added a commit to jeffmahoney/rpm that referenced this issue Apr 21, 2021
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: rpm-software-management#1648

patch-match: $LINUX_GIT must be set and point to a clone  of the upstream linux kernel
jeffmahoney added a commit to jeffmahoney/rpm that referenced this issue Apr 21, 2021
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: rpm-software-management#1648
pmatilai pushed a commit that referenced this issue Apr 26, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant