Skip to content

fix(codec): bound HELLO locator count by remaining bytes - #1237

Open
evshary wants to merge 1 commit into
eclipse-zenoh:mainfrom
ZettaScaleLabs:fix/hello-locator-count-bounds
Open

fix(codec): bound HELLO locator count by remaining bytes#1237
evshary wants to merge 1 commit into
eclipse-zenoh:mainfrom
ZettaScaleLabs:fix/hello-locator-count-bounds

Conversation

@evshary

@evshary evshary commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

This PR makes HELLO locator decoding reject impossible locator counts before allocating memory. It turns malformed locator lists into normal deserialization failures instead of very large allocation attempts.

What does this PR do?

  • Checks that the decoded locator count does not exceed the number of bytes remaining in the input buffer.
  • Rejects malformed HELLO locator lists before allocating the locator array.

Why is this change needed?

Before this change, a malformed HELLO message could decode a huge locator count and try to allocate an extremely large locator array. This PR adds a simple bounds check based on the remaining input bytes so invalid messages fail cleanly and safely.

Related Issues

eclipse-zenoh/zenoh#2592


🏷️ Label-Based Checklist

Based on the labels applied to this PR, please complete these additional requirements:

Labels: bug

🐛 Bug Fix Requirements

Since this PR is labeled as a bug fix, please ensure:

  • Root cause documented - Explain what caused the bug in the PR description
  • Reproduction test added - Test that fails on main branch without the fix
  • Test passes with fix - The reproduction test passes with your changes
  • Regression prevention - Test will catch if this bug reoccurs in the future
  • Fix is minimal - Changes are focused only on fixing the bug
  • Related bugs checked - Verified no similar bugs exist in related code

Why this matters: Bugs without tests often reoccur.

Instructions:

  1. Check off items as you complete them (change - [ ] to - [x])
  2. The PR checklist CI will verify these are completed

This checklist updates automatically when labels change, but preserves your checked boxes.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
@evshary evshary added the bug Something isn't working label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant