Fix for #217, a regression added in #205. The "header_count"
field was incremented even when we overwrote a header entry, which
caused Webdis to send a header with no name and no value.
Better handling of WS client frames, contributed in the comments of #212:
* Reject unmasked frames as per RFC 6455
* Avoid unnecessary data copy from/to evbuffer
* Remove conditions on has_mask
2 new tests cover this change:
* minimal ping-pong with masked client frame, unmasked response
* rejected unmasked client frame
Slightly adapted from a proposed change by @majklik on GitHub in
issue #212 (one invalid read fixed and a memory leak avoided).
This marks an inflight cmd's fd as -1 when the HTTP client disconnects,
which prevents the later response from Redis from being sent to a new
client which has connected in the meantime and been assigned the same
client fd.
* Remove apk cache after installing packages
* Remove unused Redis binaries: -benchmark and -cli
Those have to be done on the same line as `apk add` in order to be part
of the same image layer, since running them in a separate layer would
not affect the layer they were added to.
- Performance: avoid redundant operations when building HTTP responses.
- Fix HTTP parser bug on architectures that used unsigned "char" types.
- Fix crash when receiving "FIN" WebSocket frame (#209).
Fixes#209. A WS client socket closure could cause Webdis to schedule
the send of a closing frame, leading to both EV_READ and EV_WRITE
scheduled events. They would both fail and each lead to a call to
ws_client_free, causing a double free that ends in a crash.
http_parser.c has a table named "unhex" that it uses to convert hex
characters to their numeric values, e.g. 'F' -> 15. For non-hex
characters, the value is -1 but while the table contains int8_t values,
the extraction is done using a char. On ARMv8, char is *unsigned*, which
means it can't be compared to -1 as this is always false. Comparing to
(char)-1 instead will work.
Almost all header entries are guaranteed to be added only once, so we
don't need to check for duplicates all the time. In the current code
base only Content-Length has the potential for being added twice, and
even then it seems highly unlikely. For all others, we can now bypass
this check.
This commit also changes the header_copy flags to be 1-bit flags, so
that they can be combined.
Allocate the headers array once with the default number of entries
sufficient for most requests, and only re-allocate if needed instead of
re-allocating with each header.
http_response has an array of http_header key/value pairs, and most of
the time these use constant strings that do not need to be copied and
re-allocated. This change adds a flag tracking which values need to be
copied, were copied and need to be freed.
New feature: support for SSL connections to Redis.
Webdis can now connect securely to Redis, thanks to the Hiredis
client library. Docker images for Webdis will now contain two binaries,
"webdis" and "webdis-ssl", the latter depending on OpenSSL.
See Webdis README for details: https://github.com/nicolasff/webdis#configuring-webdis-with-ssl
Two binaries are built and packaged:
* /usr/local/bin/webdis -- still without SSL and does not depend on
OpenSSL
* /usr/local/bin/webdis-ssl -- supports SSL, depends on OpenSSL but has
to be used with the webdis image as a base image or in a container
injecting the webdis config and certs.
Security update: upgrading the version of Redis bundled in
the Webdis image to fix a number of severe vulnerabilities.
* Low severity vulnerability found in redis/redis
Description: Integer Overflow or Wraparound
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727801
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* Medium severity vulnerability found in redis/redis
Description: Out-of-bounds Read
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727803
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* High severity vulnerability found in redis/redis
Description: Allocation of Resources Without Limits or Throttling
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727783
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* High severity vulnerability found in redis/redis
Description: CVE-2021-32626
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727820
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* High severity vulnerability found in redis/redis
Description: Integer Overflow or Wraparound
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727822
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* High severity vulnerability found in redis/redis
Description: Integer Overflow or Wraparound
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727823
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* High severity vulnerability found in redis/redis
Description: Integer Overflow or Wraparound
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727825
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* High severity vulnerability found in redis/redis
Description: Integer Overflow or Wraparound
Info: https://snyk.io/vuln/SNYK-ALPINE314-REDIS-1727826
Introduced through: redis/redis@6.2.5-r0
From: redis/redis@6.2.5-r0
Fixed in: 6.2.6-r0
* Many improvements to WebSocket implementation (#198, #199). WebSocket
support is now much more stable, and better tested. The feature is
still disabled by default, but is recommended for testing.
* Base image updated from Alpine 3.12.7 to 3.14.2 to resolve
vulnerabilities found in Alpine. Webdis itself is not at risk, but
images *based* on Webdis could be using vulnerable software if they
use packages from Alpine 3.12.7.
This is not really uninitialized, it would only happen if the string
dumped with dump_string was empty of contained invalid UTF-8. Setting
an initial value has no effect since codepoint is used as an "out"
value in utf8_iterate.