Skip to content

[ul] BUG: Share underlying buffer from client/server to PDataReader#606

Merged
Enet4 merged 4 commits intoEnet4:masterfrom
naterichman:fix-read-buffer
Dec 7, 2024
Merged

[ul] BUG: Share underlying buffer from client/server to PDataReader#606
Enet4 merged 4 commits intoEnet4:masterfrom
naterichman:fix-read-buffer

Conversation

@naterichman
Copy link
Copy Markdown
Contributor

By creating a new read buffer in PDataReader, we potentially miss out on
any bytes that the receive() method read but didn't process yet.

Additionally, we lose the opposite when returning out of PDataReader:
remaining data in the PDataReader buffer that it didn't process.

The solution here is to mutably share that underlying read buffer with the
PDataReader so that it can continue from where the receive() method
left off and pass any data that it didn't read back to the read buffer
of the main Client or Server object.

By creating a new read buffer in PDataReader, we potentially miss out on
any bytes that the `receive()` method read but didn't process yet.

Additionally, we lose the opposite when returning out of `PDataReader`:
remaining data in the PDataReader buffer that it didn't process.

The solution here is to mutably share that underlying read buffer with the
`PDataReader` so that it can continue from where the `receive()` method
left off _and_ pass any data that it didn't read back to the read buffer
of the main `Client` or `Server` object.
@naterichman
Copy link
Copy Markdown
Contributor Author

Fixes #604

@Enet4 Enet4 added bug This is a bug A-lib Area: library C-ul Crate: dicom-ul labels Nov 26, 2024
@Enet4 Enet4 self-requested a review November 26, 2024 16:02
Copy link
Copy Markdown
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

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

Thank you for looking into this. I had identified a few places where the lack of buffer sharing could cause issues, but this one was probably overlooked, even though it is important.

Somewhat related, but not caused by this PR, I found that the current fuzz target test in ul/fuzz fails, so there may still be some bugs in the new PDU reading/writing impls. Hopefully there will be more opportunities to track them down. But for now, it looks good to be merged. Thanks! 👍

@Enet4 Enet4 merged commit 8b649be into Enet4:master Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lib Area: library bug This is a bug C-ul Crate: dicom-ul

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants