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

don't process JSON past the end of the buffer #619

Merged
merged 1 commit into from
Mar 24, 2024

Conversation

mcnewton
Copy link

@mcnewton mcnewton commented Mar 9, 2024

The buffer that files are read into is not zero-terminated, but deserializeJson needs a zero-terminated string. It seems that deserializeJson normally stops when it's read a full JSON document hence it usually works fine, but it's possible (especially if a file is corrupt for some reason) that it could keep processing past the end of the file. deserialiseJson accepts an optional buffer size which saves having to extend the buffer for the extra \0 char.

There are some other cases of deserializeJson, but having looked at them it seems to me that they are operating on zero-terminated buffers, so are good as-is.

deserializeJson needs size if it's not a zero-terminated string
@matjack1
Copy link
Collaborator

Thanks!

@matjack1 matjack1 merged commit c0f8fdd into esprfid:dev Mar 24, 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.

None yet

2 participants