Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Decoding a udp buffer with an argument of type blob fails with nom error EOF. #52

Closed
wants to merge 1 commit into from

Conversation

IRSMsoso
Copy link

@IRSMsoso IRSMsoso commented Jun 5, 2024

I've noticed when using decoder::decode() on a udp packet with a blob argument it fails with a nom EOF error when the blob size is a multiple of 4. I tracked this to the pad_to_32_bit_boundary() of read_blob().

let offset = (4 - original_input.offset(input) % 4) % 4;
        let (input, _) = take(offset)(input)?;
        Ok((input, ()))

This parser seems to assume that if the blob is a multiple of 4, there will be 4 more zero bytes to take(), but from my experience this isn't the case. Giving it another modulo so that multiples of 4 take 0 additional bytes fixed my issue.

Seems to work as intended now. It fixes the issue and the only other user of pad_to_32_bit_boundary is read_osc_string and that seems unaffected.
@IRSMsoso
Copy link
Author

IRSMsoso commented Jun 5, 2024

Nevermind, duplicate of #51, not sure how I didn't see that.

@IRSMsoso IRSMsoso closed this Jun 5, 2024
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.

1 participant