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

Check result code of sformat #225

Open
wants to merge 1 commit into
base: run-lints-in-ci
Choose a base branch
from

Conversation

JelteF
Copy link
Contributor

@JelteF JelteF commented Apr 7, 2020

Although we are using snprintf to make sure we don't overflow a buffer, we
don't actually check if the whole string was written in most cases. If this
would occur, this would cause very weird bugs and possibly buffer overflows
later in the code. This PR makes sure we actually check the result of sformat.
It uses macros to limit clutter on the callsite for an edge case that almost
certainly will not happen.

@DimCitus
Copy link
Collaborator

DimCitus commented Apr 7, 2020

Alternative thinking: is there a way to get the caller of the function in the logs when that happens? When using -vv or -vvv we output FILE and LINE in the logs, and that's the information we want here. What about turning sformat into a macro to have the caller information in the trace then?

@JelteF
Copy link
Contributor Author

JelteF commented Apr 7, 2020

I put an extra log_debug in the macro itself. This way file/line info should be shown there when using -vv.

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.

2 participants