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 passing NULL pointer to printf as string. #522

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

CiaranWoodward
Copy link
Contributor

@CiaranWoodward CiaranWoodward commented Jan 18, 2021

Doing this is undefined behaviour, and causes crashes with certain
compilers/C libraries. The LOG_ARG macro is defined to function as
printf.

This was causing issues when running wakaama with logs enabled.

I went through all of the LOG_ARG calls, and wrapped any string args
which could be NULL in a helper macro which swaps them for an empty
string.

Signed-off-by: Ciaran Woodward c.woodward@cascoda.com

Doing this is undefined behaviour, and causes crashes with certain
compilers/C libraries.

Signed-off-by: Ciaran Woodward <c.woodward@cascoda.com>
Copy link
Contributor

@sbertin-telular sbertin-telular left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution. I like that it only adds the null pointer check when logging is enabled.

@sbernard31 sbernard31 merged commit 7dcb5a2 into eclipse-wakaama:master Jan 19, 2021
@CiaranWoodward CiaranWoodward deleted the cia-printf-null branch January 19, 2021 12:33
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.

3 participants