Fix Index Out of Range Panic in CrLfToLfTransformer #20
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.
Hi.
I've encountered an "index out of range" panic in the CrLfToLfTransformer.Transform method of the github.com/d--j/go-milter/milterutil package. This issue arises when a \r\n sequence appears at the boundary of the src slice during transformation, leading to an attempt to access an invalid index in dst.
The current implementation seems to anticipate carriage returns (\r) and replaces them with line feeds (\n). However, when \r\n is split across the boundary of src, it results in dst[nDst-1] accessing an out-of-range index.
I have revised the existing code in the CrLfToLfTransformer.Transform method to address an issue with index out of range errors. It appears that carriage returns (\r) are already being transformed into line feeds (\n) in the existing code. Therefore, I have removed the line
dst[nDst-1] = lf
, as it seemed unnecessary and was causing the index out of range issue.Could you please review this change and confirm if it aligns with the intended behavior and resolves the identified issue?