1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
Commit graph

3643 commits

Author SHA1 Message Date
Andy Green
795d20081e coverity: 232068: hpack 6-bit index may be garbage
It's possible an attacker may send an illegal dynamic index
we can't succeed to look up
2020-08-14 08:56:19 +01:00
Andy Green
ecb8de3386 coverity: 232025: modulo with zero modulus
Add a generic helper macro that has defined operation with modulus 0
2020-08-14 08:46:31 +01:00
Andy Green
4a28bc8c87 coverity: 231739: clear false positive by needless checks
Client connection api must provide host
2020-08-14 07:27:08 +01:00
Andy Green
df2f135c09 coverity: 324692: mqtt: check for OOM in generate_id 2020-08-14 07:18:48 +01:00
Andy Green
908d259a47 coverity: 305064: clear false positive by needless NULL check
Add needless check so we don't keep getting the same coverity hit from different people
2020-08-14 07:02:07 +01:00
Andy Green
146858fb54 coverity: 231926: clear false positive by showing coverity what it wants to see
We can't get here without testing for COLON_PATH existing in http2.c as part of
the h2spec pass code.

		if (!lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_PATH) ||
		    !lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_METHOD) ||
		    !lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_SCHEME) ||
		     lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_STATUS) ||
		     lws_hdr_extant(h2n->swsi, WSI_TOKEN_CONNECTION)) {
			lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
				      "Pseudoheader checks");
			break;
		}

So there is no issue.  But show Coverity what it wants so we don't keep getting this
false positive reported by different coverity users.
2020-08-14 06:35:31 +01:00
Andy Green
7c9ead211a sspc-proxy-fragmented-dsh-must-use-fragmented-flags
We compute the refragmented flags when cutting up large client serialized
payload blocks.  But we had a bug where we didn't actually apply it and
applied the original client flags on the fragments.

That causes a crisis because EOM is used to mark end of post body and
complete the transaction, that is then happening on the first fragment.

This one-liner corrects it to use the computed, refragmented flags on the
dsh fragments and eliminate the problem.
2020-08-13 16:48:26 +01:00
Andy Green
44608abce6 sspc: fix intree build for sspc examples and increase post example body
Correct a comment about payload layout and add detailed comments about
dsh handling at proxy.

Increase the post size so it shows up fragmentation issues at the proxy.
2020-08-13 16:48:16 +01:00
Andy Green
54f98aff78 sspc: make it clear we can only get RPAR_STREAMTYPE in WAIT_INITIAL_TX state
Otherwise Coverity will complain we only set up ssi in WAIT_INITIAL_TX
2020-08-13 06:40:39 +01:00
Andy Green
d51e44388c sspc: ss timeout check is onward still alive before setting 2020-08-12 19:25:34 +01:00
Andy Green
ee404d7449 uv: cmake: use find_ only if no commandline paths
Libuv override paths were broken since the CMakeLists.txt refactor,
find_library worked OK.  This should go back to allowing both.
2020-08-12 07:26:03 +01:00
William Yu
98f63c6c8d freertos: explicitly include semphr.h
Although it's already included in lws esp-idf freertos case, in some
other freertos environments it's necessary to explicitly include
the semaphore header.
2020-08-12 05:54:27 +01:00
Andy Green
dd3bae8c71 ss: multipart without processing
Change the default to not process multipart mime at SS layer.

If it's desired, then set "http_multipart_ss_in" true in the policy on the streamtype.

To test, use lws-minimal-secure-streams-avs, which uses SS processing as it is.

To check it without the processing, change #if 1 to #if 0 around the policy for
"http_multipart_ss_in" in both places in avs.c, and also enable the hexdump in ss_avs_metadata_rx()
also in avs.c, and observe the multipart framing is passed through unchanged.
2020-08-11 11:07:13 +01:00
Andy Green
fff9ca6ee4 sspc: client: restrict forwarded bulk data to 2048 2020-08-10 15:04:10 +01:00
Andy Green
8669f6bf61 sspc: client: if not writing, make sure not to write 2020-08-10 15:04:10 +01:00
Jed Lu
793ba842fa ss: http: synthesize CONNECTED for PUT as well as POST 2020-08-10 15:04:10 +01:00
Andy Green
03af613c13 sspc: minimal examples: improve PROXY_API detection to work outside tree 2020-08-10 15:04:10 +01:00
Andy Green
629c8138b1 sai: freebsd 2020-08-10 15:04:10 +01:00
Andy Green
4cd381f933 cmake: tls: wolfssl
PARENT_SCOPE needs adjusting in a few places for wolfssl to work, and
we need a second level export of USE_WOLFSSL through lib/CMakeLists.txt

Add noi/f32 Sai build for WOLFSSL + MINIMAL_EXAMPLES
2020-08-10 15:04:10 +01:00
Andy Green
2edd83dac1 freebsd: sai build adaptations 2020-08-10 15:04:10 +01:00
Mike Owens
e3b34d3e08 Subject: Fixes to build on FreeBSD and Illumos 2020-08-10 15:04:10 +01:00
Andy Green
1f0cd18dd6 ss: server: check more carefully if built but not used on a wsi 2020-08-10 15:04:10 +01:00
Andy Green
77062d1c27 openssl: windows: also link with crypt32 in case used by openssl 2020-08-10 15:04:10 +01:00
Andy Green
74c7060c62 sspc: increase client packet size to 8192
This is only used on Linux-class devices
2020-08-10 15:04:10 +01:00
Andy Green
0f218eebbd sspc: deal with huge metadata 2020-08-10 15:04:10 +01:00
Andy Green
15e6ac25a4 sspc: make sure NUL on metadata name 2020-08-10 15:04:10 +01:00
Andy Green
6eb793bbef sspc: temp ignore txcr to support h1
We want to manage the proxy txcr, but at the moment the proxy doesn't pass
back information about if it's actually h1 or h2 it found across the internet.

Temporarily defeat txcr wait so we can support h1 until that's improved.
2020-08-10 15:04:10 +01:00
Andy Green
a71cbe785e sspc: http POST: synthesize CONNECTED to provoke client body write 2020-08-10 15:04:10 +01:00
Andy Green
d1d5cf2947 sspc: improve client async close flow 2020-08-10 15:04:10 +01:00
Andy Green
1b4bf38d5e sspc: add request_tx length variant
Add in the missing request_tx length variant, serialization and proxy
handling for it
2020-08-10 15:04:10 +01:00
Andy Green
3899a416a9 sspc: segregate client and proxy states properly 2020-08-10 15:04:10 +01:00
Andy Green
a6a9f22556 sspc: LWSSSPC: track onward request status 2020-08-10 15:04:10 +01:00
Andy Green
9a7ce85001 h2: defend against no NUL possible in log 2020-08-10 15:04:10 +01:00
Andy Green
924bd78085 clean: reduce log verbosity in various places 2020-08-10 15:04:10 +01:00
Andy Green
3b6b0b7810 ss: policy: flag to allow respecting redirects 2020-08-10 15:04:10 +01:00
Andy Green
a424623dc6 docs: add README-debugging.md and provide example points for decrypted traffic handling
Some general debugging advice but also really clarify the official way of how to dump
what is going out and coming in directly from the tls tunnel, so you can see the
actual data unencrypted.
2020-07-30 16:23:59 +01:00
Andy Green
4f84fcb124 cmake: windows: WIN32_HELPERS_PATH already ready for one-level-down CMakeLists.txt
https://github.com/warmcat/libwebsockets/issues/1992
2020-07-30 06:02:48 +01:00
Andy Green
140c1ede53 eventfd: use eventfd_read to check existence since its what we use 2020-07-29 20:36:19 +01:00
Andy Green
ddcbb6fa80 lws_interface_to_sa: confirm getifaddrs worked
We don't actually check that it provided results... return diags and
that the interface is usable if it didn't.

Also explicitly check ifa_name for being NULL, since it seems some
platforms can do that even with an ifa_addr (thanks to Jed)
2020-07-29 11:14:37 +01:00
Andy Green
5be8ff27d5 ss-server-raw
Add an example and some small changes for secure streams
serving raw data over a listening tcp socket
2020-07-28 09:21:45 +01:00
Andy Green
7eb36102a9 ss: server: h1, h2, ws basic support
Add initial support for defining servers using Secure Streams
policy and api semantics.

Serving h1, h2 and ws should be functional, the new minimal
example shows a combined http + SS server with an incrementing
ws message shown in the browser over tls, in around 200 lines
of user code.

NOP out anything to do with plugins, they're not currently used.

Update the docs correspondingly.
2020-07-27 12:05:24 +01:00
Andy Green
007a570962 lws_ss_change_handlers: allow dynamic handler change
You may use separate rx or tx handlers to neatly isolate different
rx or tx state handling, for example if the connection enters some
mode where you may send a variety of possibly large things, it can
be advantageous to have different code handling each of the
different things.

This allows you to change the rx, tx and / or state handlers to
different ones suitable for the user protocol state, if it's helpful.

With upcoming SS Server support, this has another use when SS
indicates that the underlying protocol upgraded, eg, http -> ws,
you may want to change the handlers for the different sort of
payloads expected after that, according to your user protocol.
2020-07-27 12:05:21 +01:00
Andy Green
648e25e9a8 ss: ws: observe TEXT and BINARY from policy when sending SS ws 2020-07-27 12:05:12 +01:00
Soumendra Ganguly
beacbbb38c minimal-examples: http-server-dyn: Check if the first part of received url is our mountpoint
In the case of the http-server-dyn example, there is only one protocol.
The mounts will override the area of the url space they are set up for,
and the "gaps" will fall back to the default protocol, which in turn
defaults to protocol[0] at the moment.  So you always get the dyn
protocol action on unknown parts of the URL space.

This solves that behaviour by adding a new protocols[0] that calls
straight through to the default protocol handler lws_callback_http_dummy(),
and moves the dyn handler to be protocols[1].

In addition it shows how to check the url path in the dyn handler for
cases where user code doesn't want to add the second protocol.
2020-07-27 11:53:50 +01:00
Andy Green
80ecbb754d coverity: COV294450 and COV294451 2020-07-27 11:16:49 +01:00
Andy Green
625bade63e ss: static policy: dynamic vhost instantiation
Presently a vh is allocated per trust store at policy parsing-time, this
is no problem on a linux-class device or if you decide you need a dynamic
policy for functionality reasons.

However if you're in a constrained enough situation that the static policy
makes sense, in the case your trust stores do not have 100% duty cycle, ie,
are anyway always in use, the currently-unused vhosts and their x.509 stack
are sitting there taking up heap for no immediate benefit.

This patch modifies behaviour in ..._STATIC_POLICY_ONLY so that vhosts and
associated x.509 tls contexts are not instantiated until a secure stream using
them is created; they are refcounted, and when the last logical secure
stream using a vhost is destroyed, the vhost and its tls context is also
destroyed.

If another ss connection is created that wants to use the trust store, the
vhost and x.509 context is regenerated again as needed.

Currently the refcounting is by ss, it's also possible to move the refcounting
to be by connection.  The choice is between the delay to generate the vh
being visisble at logical ss creation-time, or at connection-time.  It's anyway
not preferable to have ss instantiated and taking up space with no associated
connection or connection attempt underway.

NB you will need to reprocess any static policies after this patch so they
conform to the trust_store changes.
2020-07-21 12:43:32 +01:00
Andy Green
9e6cefcfad lws_netdev: fix rssi averaging 2020-07-21 08:16:01 +01:00
Andy Green
08bc9bf410 ss: http: handle rx DESTROY_ME 2020-07-21 07:57:15 +01:00
Andy Green
195fe76f42 cmake: document implications of LWS_WITH_DISTRO_RECOMMENDED 2020-07-21 07:57:15 +01:00
Andy Green
3310d228cf context: focus context init logging
Tighten up the logging at info and have a build summary and version info
at notice level like this

[2020/07/19 07:01:07:5563] N: LWS: 4.0.99-v4.0.0-232-gd602af468, loglevel 1031
[2020/07/19 07:01:07:5567] N: NET IPv6-absent H1 H2 WS MQTT SS-JSON-POL SSPROX ASYNC_DNS
2020-07-20 06:28:55 +01:00