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 segmentation fault of lws_snprintf #3212

Closed
wants to merge 1 commit into from

Conversation

zzblydia
Copy link
Contributor

@zzblydia zzblydia commented Aug 23, 2024

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 to p += lws_snprintf(p, lws_ptr_diff_size_t(end, p), "\x0d\x0a");

The SIGSEGV stack trace on suse platform is as follows:

#0 vsnprintf (string=0x0, maxlen=93824992762488, ....) at ...
#1 lws_snprintf (str=0x0, size=93824992762488, ...) at libwebsockets.c:762
#2 lws_generate_client_handshake (...) at client-http.c:1296

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.

@lws-team
Copy link
Member

lws-team commented Nov 3, 2024

Thanks, it's pushed on main.

@lws-team lws-team closed this Nov 3, 2024
@zzblydia zzblydia deleted the main_20240823 branch November 3, 2024 14:08
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