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

Avoid passing NULL to vprintf(). #1552

Merged
merged 1 commit into from Oct 22, 2018
Merged

Avoid passing NULL to vprintf(). #1552

merged 1 commit into from Oct 22, 2018

Conversation

madpilot78
Copy link
Contributor

The die function is called with NULL as second argument in https://github.com/madpilot78/monitoring-plugins/blob/master/plugins/check_http.c#L939.

I'm almost sure that passing a NULL as the format string to printf functions falls in the undefined behavior category. In FreeBSD this causes a segmentation fault.

This simple patch checks for fmt not to be NULL and only it is not NULL proceeds to call the vprintf.

It avoids the segmentation fault on my systems.

@ott
Copy link

ott commented Oct 19, 2018

C11 does not seem to define the behaviour of vprintf if the format string is NULL. The patch looks good to me.

@sni sni merged commit 82a634f into monitoring-plugins:master Oct 22, 2018
@sni
Copy link
Contributor

sni commented Oct 22, 2018

thanks

@madpilot78 madpilot78 deleted the Avoid_passing_NULL_to_vprintf branch October 22, 2018 17:55
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

3 participants