Repository navigation
Fix for #185 - #186
Open
minghia wants to merge 2 commits into
Open
Fix for #185#186minghia wants to merge 2 commits into
minghia wants to merge 2 commits into
Conversation
calculation doesn't raise a java.nio.BufferOverflowException.
leif81
self-requested a review
September 12, 2026 19:48
leif81
requested changes
Oct 15, 2026
| SignalPdu spdu = new SignalPdu(); | ||
| final int numChunks = 10; | ||
| byte[] data = new byte[numChunks]; | ||
| byte[] data = new byte[numChunks+2]; |
Author
There was a problem hiding this comment.
From memory it was added to test if the data size is a multiple of 4 bytes. The code prior to my change would try and pad the Signal PDU to a 4 bytes boundary. But in the case of the dataLength not being a multiple of 8, the padding code would try and pad past the end of buff.
`int nrOfBytes = 0;
nrOfBytes = dataLength / Byte.SIZE;
buff.put(data); // This will but the whole data object into buff. **This should use buff.put(data, 0, nrOfBytes); **
int paddingBytes = nrOfBytes % 4; // and this may not be zero`
The test case was modified to test this case, where the data is not a multiple of 4 bytes but the array containing the data is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Made the write to the ByteBuffer use the number of bytes supplied.