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

Integer types in header data should be interpreted as unsigned #48

Closed
aft90 opened this issue Mar 16, 2024 · 0 comments
Closed

Integer types in header data should be interpreted as unsigned #48

aft90 opened this issue Mar 16, 2024 · 0 comments

Comments

@aft90
Copy link
Contributor

aft90 commented Mar 16, 2024

Sorry if the title isn't clear, but basically when an index record says that its data is of type, say, RPM_INT16_TYPE, the corresponding data should be interpreted as an unsigned integer, whereas currently the implementation interprets it as signed.

Here is a reference to the RPM docs saying so: https://github.com/rpm-software-management/rpm/blob/master/docs/manual/tags.md#scalar-types

There are four unsigned integer types for RPM tags:

Additionally, if you look in the rpm C code, you can see there are a lot of references to headers using unsigned int values for data, and none using signed ints - for instance here: https://github.com/rpm-software-management/rpm/blob/master/include/rpm/header.h#L205

Anecdotally, I first realised this was an issue when I was using your library to test some RPMs I'm building with an automated tool. I wanted to verify the permissions on the files were being set right so I retrieved headers['filemodes'][x] and tried to use the stat functions on the value (the RPM spec says that filemodes should be identical to st_mode in struct stat). However I kept getting OverflowError: can't convert negative value to unsigned int which made me wonder if the values ought to be unsigned.

If I understand the issue correctly, it should be a small change to extract_int16 and extract_int32. I'll raise a PR shortly.

hello-2.12.1-2.fc39.x86_64.rpm.gz

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

No branches or pull requests

2 participants