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

Truncates payload if it doesn't fit in buffer #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oeretana
Copy link

When function Adafruit_MQTT::publishPacket constructs the MQTT packets to be published, no validation was done to make sure that the function never writes more than MAXBUFFERSIZE into buffer. This could lead to very difficult to debug problems, because the program quickly crashes after writing more than MAXBUFFERSIZE into buffer. This proposed change truncates the payload (only if necessary) to fit buffer. Of course, truncating the payload is still a problem, but it is easier to debug and find. A debug message will let know that the payload was truncated to fit MAXBUFFERSIZE.

When function Adafruit_MQTT::publishPacket constructs the MQTT packets to be published, no validation was done to make sure that the function never writes more than MAXBUFFERSIZE into buffer. This could lead to very difficult to debug problems, because the program quickly crashes after writing more than MAXBUFFERSIZE into buffer. This proposed change truncates the payload (only if necessary) to fit buffer. Of course, truncating the payload is still a problem, but it is easier to debug and find. A debug message will let know that the payload was truncated to fit MAXBUFFERSIZE.
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.

None yet

1 participant