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

JTEncode.cpp can cause unterminated character array, leading to undefined behavior #35

Open
EngineerGuy314 opened this issue Feb 10, 2025 · 0 comments

Comments

@EngineerGuy314
Copy link

this is regarding lines 677 to 687 in the wspr_message_prep function in JTEncode.cpp.

The code cycle through 12 characters of "call", and unless a char is '/', '<' or '>' it replaces non digits or non uppercase characters with a space.

The problem is if "call" points to a 6 character callsign that is null terminated in the 7th character, then the code replaces the null with a space. You now have an unterminated character array with undefined garbage in characters 8 through 12.

Not an issue 99% of the time, because the garbage characters will probably also be replaced by spaces.

But every once in a while the garbage characters include a '/' which will not get replaced with a space. The downstream code sees the '/' and thinks your trying to send a WSPR Type-3 message with prefix, and you end up with an incorrectly encoded WSPR message.

A workaround is to make sure any string you pass for the call is padded with spaces to the 12th character. A better solution imho is if the code in lines 677 to 687 would leave NULLs alone.

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

No branches or pull requests

1 participant