diff --git a/lib/handshake.c b/lib/handshake.c index c22c4063..dafccef2 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -340,8 +340,6 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi) */ if (wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token_len) { - strcpy(p, "\x0d\x0aSec-WebSocket-Extensions: "); - p += strlen("\x0d\x0aSec-WebSocket-Extensions: "); /* * break down the list of client extensions @@ -410,6 +408,10 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi) if (ext_count) *p++ = ','; + else { + strcpy(p, "\x0d\x0aSec-WebSocket-Extensions: "); + p += strlen("\x0d\x0aSec-WebSocket-Extensions: "); + } p += sprintf(p, "%s", ext_name); ext_count++; @@ -444,7 +446,6 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi) } } - /* end of response packet */ strcpy(p, "\x0d\x0a\x0d\x0a");