fix segmentation fault of lws_snprintf #3212
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am working with libwebsockets v4.3.0 as a ws client.
It bears resemblance to #3171, differing in that I don't handle the callback LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER. so the null pointer
p
comes top += lws_snprintf(p, lws_ptr_diff_size_t(end, p), "\x0d\x0a");
The SIGSEGV stack trace on suse platform is as follows:
I have observed numerous instances of the usage of
p += lws_snprintf(p, ...)
.so I believe it would be prudent to verify the null pointer within the functions lws_snprintf and lws_strncpy.