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

Fix unpacking time (unsigned int) from octets for large values #1836

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vanitasvitae
Copy link
Contributor

Time, as well as offsets (e.g. expiration) in OpenPGP are stored as seconds in unsigned Integers.

I noticed, that 8385a2c broke some tests in PGPainless that dealt with large expiration time intervals.

Turns out, the changed code accidentally converted the values to signed ints, which break for large (but legal) intervals.

The patch converts back to an unsigned value.

@vanitasvitae
Copy link
Contributor Author

I wonder if more places in the code are affected by this, e.g. key creation time...

@vanitasvitae
Copy link
Contributor Author

PublicKeyPacket and SignaturePacket were also affected by this.

I also discovered a discrepancy between StreamUtils.writeTime() (expecting seconds) and StreamUtils.readTime() (returning millis).

I fixed this by changing writeTime() to expect millis and introducing writeSeconds() and readSeconds() dealing with seconds.

@vanitasvitae
Copy link
Contributor Author

Okay, now I wonder, if large values are handled properly in general (e.g. large lengths) :D

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 this pull request may close these issues.

1 participant