-
Notifications
You must be signed in to change notification settings - Fork 9
gateway/uplink: bound writes against the block-pool constant #313
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,14 @@ | |
| /** Maximum ciphertext size without the length of the size field */ | ||
| #define MAX_BLOCK_SIZE_FIELD_VALUE (MAX_CIPHERTEXT_BLOCK_SIZE - sizeof(uint16_t)) | ||
|
|
||
| /* | ||
| * CONFIG_POUCH_BLOCK_SIZE feeds LOG2() above, which rounds DOWN to a power of two. | ||
| * A non-power-of-two value silently yields a smaller block everywhere it is used. Reject it at build | ||
| * time so the configured size is the size actually used. | ||
| */ | ||
| POUCH_STATIC_ASSERT((CONFIG_POUCH_BLOCK_SIZE & (CONFIG_POUCH_BLOCK_SIZE - 1)) == 0, | ||
| "CONFIG_POUCH_BLOCK_SIZE must be a power of two"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually explicitly want to avoid this, as the rounding down is deliberate on the device side. As the block size always has to be a power of two, rounding down works well here as well, as long as we account for it when calculating the capacity of the block. I made a counter proposal for this problem in #336, which changes the uplink module to use the appropriate block API for calculating the capacity of the buffer. |
||
|
|
||
| int block_decode_hdr(struct pouch_bufview *v, | ||
| uint16_t *block_size, | ||
| uint8_t *stream_id, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.