Skip to content

Conversation

@quark9981
Copy link
Contributor

Description

This PR fixes a buffer overflow vulnerability in the USRP recv_stream function that caused crashes during data reception.

Problem

When receiving data from USRP devices (tested with B210), the memcpy operation could write beyond the allocated buffer boundary, causing a "buffer overflow detected" error and application termination.

Solution

  • Added boundary check before memcpy to prevent buffer overflow
  • Calculate safe copy length to avoid writing beyond buffer bounds
  • Added break condition when buffer is completely filled
  • Fixed type mismatch by changing current_index from int to size_t
  • Improved memory management by freeing result buffer on second malloc failure

Testing

Tested with USRP B210 device:

  • Multiple receive sessions completed successfully
  • No buffer overflow errors
  • Application runs stably without crashes

Related Issue

Fixes buffer overflow crash when receiving data with USRP devices.

- Add boundary check before memcpy to prevent buffer overflow
- Calculate safe copy length to avoid writing beyond buffer bounds
- Add break condition when buffer is filled
- Fix type mismatch by changing current_index from int to size_t
- Improve memory management by freeing result buffer on second malloc failure
@CLAassistant
Copy link

CLAassistant commented Nov 27, 2025

CLA assistant check
All committers have signed the CLA.

@andynoack
Copy link
Collaborator

Thank you for contributing this fix!

@andynoack andynoack merged commit 9cbbab3 into jopohl:master Nov 27, 2025
9 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.

3 participants