diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 09e83bda..3a8de9b1 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -31,7 +31,7 @@ struct libwebsocket *libwebsocket_client_connect_2( lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS), wsi->u.hdr.ah->c_port); - if (context->proxy_basic_auth_token) + if (context->proxy_basic_auth_token[0]) plen += sprintf((char *)context->service_buffer + plen, "Proxy-authorization: basic %s\x0d\x0a", context->proxy_basic_auth_token); diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 984a3d7f..cb4a9efd 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -714,7 +714,7 @@ libwebsocket_set_proxy(struct libwebsocket_context *context, const char *proxy) if ((unsigned int)(p - proxy) > sizeof(authstring) - 1) goto auth_too_long; - strncpy(authstring + 6, proxy, p - proxy); + strncpy(authstring, proxy, p - proxy); // null termination not needed on input if (lws_b64_encode_string(authstring, (p - proxy), context->proxy_basic_auth_token,