Commit graph

1705 commits

Author SHA1 Message Date
Brown, Matthew
3d48ce8f09 Added option to build the static library with PIC 2016-09-27 05:37:58 +08:00
Patrick Gansterer
a2241384e7 Add SVG to lws_get_mimetype() 2016-09-23 06:31:50 +08:00
Andy Green
5a247a57d2 v2.0.3 2016-09-15 03:07:47 +08:00
Andy Green
1f02bd2e66 lws_snprintf
Thanks to Fabrice Gilot for reporting the problem that led to uncovering this.

Due to a misunderstanding of the return value of snprintf (it is not truncated according
to the max size passed in) in several places relying on snprintf to truncate the length
overflows are possible.

This patch wraps snprintf with a new lws_snprintf() which does truncate its length to allow
the buffer limiting scheme to work properly.

All users should update with these fixes.
2016-09-15 02:54:32 +08:00
Andy Green
d7fb6ad9cf handle rx flow control active when consuming payload
https://github.com/warmcat/libwebsockets/issues/622
2016-09-10 04:44:56 +08:00
Andy Green
2aa6f1bccd adopt_socket_vhost: error path doesn't remove us from timeout list
As found by "github user 7"

https://github.com/warmcat/libwebsockets/issues/621
2016-09-09 08:31:56 +08:00
Andy Green
0f7e4dbd48 coverity 169271 - take care about sockfd of -1 on close 2016-08-28 09:54:30 +08:00
Patrick Gansterer
6a75dca024 Update badges in README.md
Fix the link to Appveyor and use SVG images.
2016-08-27 05:59:43 +08:00
Patrick Gansterer
b7473a354d Remove unneeded #include <stdint.h>
This fixes the build for Visual Studio 2008.
2016-08-26 19:41:31 +08:00
Andy Green
a86666cfe5 update changelog for v2.0.2 release that went out without it 2016-08-26 07:37:25 +08:00
Patrick Gansterer
4324ea598b Add error handling for SSL_new() of clients
Do not access wsi->ssl if SSL_new() failed and log the error.
2016-08-14 19:54:12 +08:00
Andy Green
d4410f1d07 server max protocol element 64
https://github.com/warmcat/libwebsockets/issues/601
2016-08-11 05:53:54 +08:00
Andy Green
f0789545e7 SNI-vhost-matching-fallback-to-wildcard 2016-07-11 09:56:56 +08:00
Robin Rowe
7d45a746d6 fix __x86_64__ check
https://github.com/warmcat/libwebsockets/issues/574
2016-06-30 02:14:03 +08:00
Andy Green
3382efe5d6 client confirm server hostname in cert
Openssl v1.0.2 and above have support for checking the hostname
the client side connected to against the hostname on the cert the
server presented.

This enables that feature if the necessary API is available in the
openssl version, meaning the connection will fail at ssl negotiation if the
cert isn't for the requested server

It's very easy to test, add a fake entry to /etc/hosts for the server IP with
a different name, using that will fail at ssl but using the correct dns name
matching the certificate will work.
2016-06-28 20:25:46 +08:00
Gadkari Mugdha
c1e14e7f6c fix for https connection code 2016-06-13 17:20:27 +08:00
Karl Palsson
27b7055ac6 non-openssl: only check for openssl ecdh in openssl builds
See also
https://github.com/warmcat/libwebsockets/issues/559

Signed-off-by: Karl Palsson <karlp@etactica.com>
2016-06-07 19:52:13 +08:00
Andy Green
f6f2dfc7fd client CONNECTION_ERROR also allow in LWSS_CLIENT_UNCONNECTED
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-07 17:26:11 +08:00
Andy Green
e746a993d0 lws_ssl_client_connect2 remove duplicate close on error path
https://github.com/warmcat/libwebsockets/issues/532

Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-07 01:34:02 +08:00
Andy Green
5f0dc8f4e6 ARRAY_SIZE dont redefine
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-06 20:34:33 +08:00
Andy Green
b064fb5bc9 v2.0.2
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-06 19:59:30 +08:00
Martin C Drohmann
15bb297fbb Revert changes in daemonize.c from commit 22d6f39e7f 2016-06-02 13:06:32 +08:00
Young
83a79ec381 update document for lws_get_context 2016-06-01 08:38:39 +08:00
Fabian Kurz
9694e5194c lwsl_timestamp month off by one 2016-06-01 08:38:27 +08:00
Andy Green
0f222cdc77 output size trimming with default rxbuf fix
5e203f78e2 accidentally
trashed the "zero rz_buffer_size means 4096" handling
for tx chunking.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-15 09:01:43 +08:00
Andy Green
62a8b0cb33 appveyor libuv integration
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-15 09:01:30 +08:00
Andy Green
73f859d9e7 lwsws conf mount extra mimetypes
This patch adds the ability to provide extra mimtypes on a mount.

lwsws conf learns how to do them.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 10:48:28 +08:00
Andy Green
37320ced18 lejp handle name elements starting with dot
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 10:25:52 +08:00
Andy Green
3bd3a41e97 lwsws conf allow setting cipher list and ecdh curve
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 08:34:29 +08:00
Andy Green
bc3f77e977 win32 more build fixes
After alexgille

https://github.com/warmcat/libwebsockets/issues/526

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 06:56:31 +08:00
Andy Green
7d259d885a access_log ensure no reuse of freed log area
Valgrind caught http/1.1 pipelining using dead user agent alloc
for logging... NULL it when we free it since the wsi can be
reused with keepalive

==16208== Invalid free() / delete / delete[] / realloc()
==16208==    at 0x4847ACC: free (vg_replace_malloc.c:530)
==16208==    by 0x4888DC3: _realloc (alloc.c:8)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x487DBCB: lws_access_log (libwebsockets.c:2352)
==16208==    by 0x48956DF: lws_http_transaction_completed (server.c:1245)
==16208==    by 0x4893757: lws_http_serve (server.c:340)
==16208==    by 0x48946EF: lws_http_action (server.c:748)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==  Address 0x552e5f8 is 0 bytes inside a block of size 86 free'd
==16208==    at 0x4847ACC: free (vg_replace_malloc.c:530)
==16208==    by 0x4888DC3: _realloc (alloc.c:8)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x487DBCB: lws_access_log (libwebsockets.c:2352)
==16208==    by 0x48956DF: lws_http_transaction_completed (server.c:1245)
==16208==    by 0x4893757: lws_http_serve (server.c:340)
==16208==    by 0x48946EF: lws_http_action (server.c:748)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==  Block was alloc'd at
==16208==    at 0x4846498: malloc (vg_replace_malloc.c:298)
==16208==    by 0x4848D57: realloc (vg_replace_malloc.c:785)
==16208==    by 0x4888DA7: _realloc (alloc.c:6)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x4893EAF: lws_http_action (server.c:565)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==    by 0x48994B7: lws_io_cb (libuv.c:101)
==16208==    by 0x4AE7B1F: ??? (in /usr/lib/libuv.so.1.0.0)


Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 11:00:45 +08:00
Andy Green
9c0cc42707 asserts log which
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 10:59:44 +08:00
Sterling Jensen
85213516d3 Fix leak caused by undestroyed pthread mutex 2016-05-13 09:42:58 +08:00
Andy Green
f92ed9c7a7 win32 libuv related build fixes
https://github.com/warmcat/libwebsockets/issues/526

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 08:22:03 +08:00
Andy Green
36699d6ecb v2.0.1
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-12 22:29:06 +08:00
Andy Green
1cea325a42 check oom on lws_malloc
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-12 21:53:57 +08:00
Andy Green
d5c43f4a6e windows no chown on log file generation
https://github.com/warmcat/libwebsockets/issues/524

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-11 19:00:15 +08:00
Andy Green
3baed037c9 output allow LWS_PRE+4 on top of rx_buffer_size for max send chunk
https://github.com/warmcat/libwebsockets/issues/522

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-10 21:37:58 +08:00
Andy Green
0b208559e0 logging migrate user stimulated logging to info
https://github.com/warmcat/libwebsockets/issues/520

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-09 13:32:53 +08:00
Andy Green
fc29185b9f POST handling dont autocomplete transaction
Until now lws has finished the HTTP transaction when the POST body was
completely received.

However that needlessly makes it impossible to send a HTTP 200 and a
response without a redirect.

This changes lws behaviour after sending the LWS_CALLBACK_HTTP_BODY_COMPLETION
callback to no longer terminate the HTTP transaction.

If you want the old behaviour, you can terminate the transaction with
lws_http_transaction_completed() in the LWS_CALLBACK_HTTP_BODY_COMPLETION
callback.

Otherwise it's now possible to call lws_callback_on_writable() from
LWS_CALLBACK_HTTP_BODY_COMPLETION.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-09 10:08:13 +08:00
Andy Green
0daa1869b2 libuv tidy up destroy and disable timer races during shutdown
Also don't make us wait 1s for init to finish.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:11:19 +08:00
Andy Green
b1150df2f5 client fix for operation with libuv
- libuv socket init binding was missing for client

 - failures like no ws protocol match are deferred until the
   ah is bound.  Check for these failures and make sure we
   tell the guy trying to set up the client connection the
   wsi is NULL if it has already failed and closed.

 - pfd.events was not initialized for the client init path

With this general client function is more robust but also
client connections work properly with libuv.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:11:07 +08:00
Andy Green
465e2660e3 context only destroy protocols if init got sent
If for some reason we exit before the protocol init action
(which is delayed for libuv) we should not send the protocol
destroy messages

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:10:51 +08:00
Andy Green
792713f2c1 client handle connection fail at second phase properly
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:10:38 +08:00
Andy Green
e36ce9b20e test server post also take care about POST len termination
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:10:24 +08:00
Andy Green
7624a8b128 update api docs v2.0
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-07 14:26:32 +08:00
Andy Green
179b3ed9ff fix %3d handling in path part and add attack.sh
https://github.com/warmcat/libwebsockets/issues/518

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-07 08:32:44 +08:00
Andy Green
79b1519b01 protocol plugins default also add example in test server v2.0
This shows how to deliver per-vhost, per-protocol option
name:value pairs using code.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 15:57:17 +08:00
Andy Green
172c78a43a protocol plugins set default
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 14:42:37 +08:00
Andy Green
e2bf142912 mimetypes add additional canned
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 08:08:48 +08:00