Skip to content

fix: cap advertised max buffer size at 2^24 - 1 - #45

Open
tomfitzhenry wants to merge 1 commit into
9elements:mainfrom
tomfitzhenry:pr/serprog-max-buffer-size
Open

fix: cap advertised max buffer size at 2^24 - 1#45
tomfitzhenry wants to merge 1 commit into
9elements:mainfrom
tomfitzhenry:pr/serprog-max-buffer-size

Conversation

@tomfitzhenry

Copy link
Copy Markdown
Contributor

The 16 MiB constant (16 << 20) is exactly 2^24, but the serprog length field is 24-bit little-endian, so it wrapped to zero: QWrNMaxLen and QRdNMaxLen replied with a maximum length of 0. Use 2^24 - 1 so the advertised maximum is representable.

FWIW, flashrom works around this bug: https://github.com/flashrom/flashrom/blob/main/programmers/serprog.c#L784-L785

The 16 MiB constant (16 << 20) is exactly 2^24, but the serprog length
field is 24-bit little-endian, so it wrapped to zero: QWrNMaxLen and
QRdNMaxLen replied with a maximum length of 0. Use 2^24 - 1 so the
advertised maximum is representable.
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