Skip to content

fixes: Random fixes / improvements#239

Merged
ceolin merged 2 commits into
HubbleNetwork:mainfrom
ceolin:random-fixes
Jun 11, 2026
Merged

fixes: Random fixes / improvements#239
ceolin merged 2 commits into
HubbleNetwork:mainfrom
ceolin:random-fixes

Conversation

@ceolin

@ceolin ceolin commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator
  • Fix possible off by one issue in _encode. Although it is not a problem right now because of the size of buffers we use, the algorithm itself has an issue and may cause a problem in future.
  • Seed PRNG in FreeRTOS to avoid possible same random values across boots

Bound the check against the padded (ceil) symbol count so the out-of-bounds
case is rejected with -EINVAL. Not reachable at current field sizes, but the
check was incorrect and fragile against future size changes.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Seed the C library PRNG the first time hubble_rand_get() is called so
the random sequence is not identical across boots.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>

@HongNguyen635 HongNguyen635 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably another PR but while re-reading the hubble_bitarray, I don't think I saw the len field being used anywhere. Is this a remnant from an old design? If so, is it safe to remove then?

@ceolin ceolin merged commit 677c89f into HubbleNetwork:main Jun 11, 2026
8 checks passed
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.

2 participants