Commit graph

2159 commits

Author SHA1 Message Date
Andy Green
f94bef42c4 lws_header_table_reset: make caller responsibility to clear down ah rx buffer
There are two kinds of reaason to call lws_header_table_reset(), one is we are reallocating
a destroyed ah to another wsi, and the other is we are moving to the next pipelined header set
still on the same wsi, and we need a "weaker" reset that only clears down the state related
to the header parsing, not everything about the ah context including the ah rx buffer.

This patch moves the ah rxbuffer rxpos and rxlen resetting out of lws_header_table_reset() and to
be the responsibility of the caller.  Callers who are moving the ah to another wsi are
patched to deal with resetting rxpos and rxlen and lws_http_transaction_completed() who only
resets the ah when moving to the next pipelined headers, no longer wrongly clears the ah rxbuf.

https://github.com/warmcat/libwebsockets/issues/638
2016-09-29 10:31:06 +08:00
Brown, Matthew
b0ff623526 Added option to build the static library with PIC 2016-09-27 05:32:40 +08:00
Benjamin Ness
668a6fbf29 fix build problem on systems without X509_VERIFY_PARAM type 2016-09-27 05:28:11 +08:00
Patrick Gansterer
e468e15a2b Add SVG to lws_get_mimetype() 2016-09-23 06:31:24 +08:00
Andy Green
0c984014f0 lwsws license to cc0
https://github.com/warmcat/libwebsockets/issues/629
2016-09-19 19:16:47 +08:00
Andy Green
a496700b3a 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:22:57 +08:00
Andy Green
c15714f35a handle rx flow control active when consuming payload
https://github.com/warmcat/libwebsockets/issues/622
2016-09-10 04:54:20 +08:00
Andy Green
b8199ba4ab generic-table: format-security
https://github.com/warmcat/libwebsockets/issues/624
2016-09-10 04:54:20 +08:00
Andy Green
2083674aa0 lws_status protect against pss list changing 2016-09-10 04:54:20 +08:00
Andy Green
9c7e84d346 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-10 04:54:20 +08:00
Fredrik Skogman
6ecbe3e93f Do not use ps fax on Solaris. 2016-09-10 04:53:31 +08:00
Fredrik Skogman
9c04a107c9 Updated test programs to build on Solaris. Some whitespaces cleanup. 2016-09-10 04:53:28 +08:00
Fredrik Skogman
316960b87d Added build support for Solaris. 2016-09-09 06:52:42 +08:00
Fredrik Skogman
9de43fc9d7 Check for sys/sockio.h. 2016-09-09 06:48:24 +08:00
Andy Green
723b3f16fa client http: extra read notification after close
https://github.com/warmcat/libwebsockets/issues/620
2016-09-06 15:36:51 +08:00
Andy Green
64dd359192 windows: WCHAR in lws_plat_inet_ntop needs double the final allocation
https://github.com/warmcat/libwebsockets/issues/619
2016-09-05 15:03:37 +08:00
Andy Green
72502e86f5 coverity 169276-9 - false positive assuming 8b char: char limits index size 2016-08-28 09:49:30 +08:00
Andy Green
d11bee7fc5 coverity 169274 - lwsgt dirlisting ignore files that cant be statted 2016-08-28 09:44:15 +08:00
Andy Green
01020b60f6 coverity 169273 - off-by-one on cgi chunking swallow limit 2016-08-28 09:44:15 +08:00
Andy Green
d6761e87b5 coverity 169272 - off-by-one possible on CGI buffer limit 2016-08-28 09:44:15 +08:00
Andy Green
d8e051dd97 coverity 169271 - take care about sockfd of -1 on close 2016-08-28 09:44:15 +08:00
Andy Green
2f863cf59a coverity 169269 - dont issue NULL cce 2016-08-28 09:44:15 +08:00
Andy Green
cd02a15669 coverity 169268 + 169270- dead code plus repeat NULL check on error path 2016-08-28 09:44:15 +08:00
Andy Green
e0212b8c85 coverity 169275 - lwsgt check string bounds 2016-08-28 09:44:15 +08:00
Andy Green
16f3e4cacf coverity 169267 - lwsgt strncpy may fill buffer without NUL 2016-08-28 09:10:40 +08:00
Andy Green
e35d91a860 per-vhost headers and lwsws conf support
This l;ets you add per-vhost arbitrary headers on served files, eg

     "headers": [{
        "X-Content-Type-Options": "nosniff",
        "X-XSS-Protection": "1; mode=block",
        "x-frame-options": "SAMEORIGIN"
        }],
2016-08-27 17:07:06 +08:00
Patrick Gansterer
46646f9ebf Update badges in README.md
Fix the link to Appveyor and use SVG images.
2016-08-27 05:57:18 +08:00
Patrick Gansterer
396b58ce70 Remove unneeded #include <stdint.h>
This fixes the build for Visual Studio 2008.
2016-08-26 18:31:09 +08:00
Andy Green
a5ec7212ff test html: js date uses ms 2016-08-23 18:29:17 +08:00
Andy Green
6fe25fd1fd cgi-retain-timeout-after-POST-send
Sending the POST data isn't enough to let us off the hook for timeout checks, if we
are doing a CGI on it.
2016-08-23 14:20:11 +08:00
Andy Green
b49b0fbafa quench logging 2016-08-22 07:07:10 +08:00
Andy Green
1172a89bb3 cgi: deal with all methods correctly 2016-08-20 06:46:17 +08:00
Andy Green
90f513b209 uv: dont handle SIGSEGV, SIGFPE
https://github.com/warmcat/libwebsockets/issues/609
2016-08-20 05:47:29 +08:00
Patrick Gansterer
fa9ebb394f Remove context from lws_context_per_thread for non-libuv builds
The variable is never read when built without libuv.
2016-08-14 20:55:24 +08:00
Patrick Gansterer
5162d876fd 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:53:20 +08:00
Patrick Gansterer
d0abf9bb5e Fix signature of lws_create_vhost() in README.coding.md 2016-08-14 19:48:59 +08:00
Patrick Gansterer
387e50bd8f Allow serving files without known mimetype
RFC2616 only says that any HTTP/1.1 message containing an entity-body
SHOULD include a Content-Type header field defining the media type of
that body.
RFC2119 defines SHOULD as: This word mean that there may exist valid
reasons in particular circumstances to ignore a particular item, but
the full implications must be understood and carefully weighed before
choosing a different course.

AG: this isn't an oversight, it's paranoia about sending out /etc/passwd
or /etc/shadow accidentally.

I agree it should be allowed if people really want to override it.  But
the default should remain like it is I think.

I adapted the patch to allow the extra mimetype "*": "" to be declared on
a mount, as a wildcard match that serves the file without a Content-Type.
2016-08-14 19:28:29 +08:00
Andy Green
3ffd0eb84a server max protocol element 64
https://github.com/warmcat/libwebsockets/issues/601
2016-08-11 05:36:08 +08:00
Andy Green
95fff47a91 client-add-PUSH-http-body-capability
Support HTTP body sending on client connections.

Add demo to test-client.

Run the normal test server, then

$ libwebsockets-test-client http://localhost:7681/formtest -o

It will post the string "hello" to the POST test using application/x-www-form-urlencoded

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

Also ensures any of the Client HTTP transient modes will call back LWS_CALLBACK_CLOSED_CLIENT_HTTP
if they close

https://github.com/warmcat/libwebsockets/issues/600
2016-08-10 21:23:01 +08:00
Andy Green
bbf93693d8 client fixups after esp8266 2016-08-10 21:23:01 +08:00
Andy Green
7acf76cd3d esp8266 initial support 2016-08-10 21:20:23 +08:00
Andy Green
f7a1c7ed47 base64 decode fix lengths 2016-08-10 21:20:23 +08:00
Andy Green
4606ad4377 ah detach: don't print held time if actually detached
Confusingly an ah held time was printed for a previously detached ah.

Clear down the time field when detaching the ah so this can't happen any more.
2016-08-10 21:20:23 +08:00
Andy Green
f32d25051c ws ping pong on idle connections
This adds a new member to the context creation info struct "ws_ping_pong_interval".

If nonzero, it sets the number of seconds that established ws connections are
allowed to be idle before a PING is forced to be sent.  If zero (the default) then
tracking of idle connection is disabled for backwards compatibility.

Timeouts cover both the period between decision to send the ping and it being
sent (because it needs the socket to become writeable), and the period between
the ping being sent and the PONG coming back.

INFO debug logs are issues when the timeout stuff is operating.

You can test the server side by running the test server hacked to set ws_ping_pong_interval
and debug log mask of 15.  Both the mirror protocol and the server-status protocol are
idle if nothing is happening and will trigger the PING / PONG testing.  (You can also
test using lwsws and /etc/lwsws/conf with "ws-pingpong-secs": "20" in the global section)

For client, run the test client with -n -P 20 for 20s interval.  -n stops the test client
writing using the mirror protocol, so it will be idle and trigger the PING / PONGs.

The timeout interval may be up to +10s late, as lws checks for affected connections every
10s.
2016-08-10 21:20:23 +08:00
Andy Green
0fa6821214 Plugin server-status cleanup 2016-08-10 21:20:23 +08:00
Andy Green
2671b7469a plugins-dim-webpage-when-connection-lost 2016-07-14 08:57:28 +08:00
Andy Green
722cc4a366 plugin table dirlisting 2016-07-14 08:57:28 +08:00
Andy Green
02f880d9b6 doxygen use sections 2016-07-14 08:57:28 +08:00
Mike Messina
efef6bf9a0 Recheck slot when an FD gets closed and make formatting consistent 2016-07-14 08:57:28 +08:00
mmessina
fc0e52da9e Use one event for all sockets to avoid 64 limit and fix the single dispatch issue 2016-07-14 08:57:28 +08:00