diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-22 10:27:47 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-22 10:29:06 -0700 |
| commit | 959eabe2675a3b8be9bc2b2459cc899a5a64b283 (patch) | |
| tree | 373fba9ab3c7cf4c769efb1c42f896694bf16d25 /src/compat | |
| parent | 67f5ed6e5c0dd7bdd9002bbb519ab34f35fef8dd (diff) | |
| download | nng-959eabe2675a3b8be9bc2b2459cc899a5a64b283.tar.gz nng-959eabe2675a3b8be9bc2b2459cc899a5a64b283.tar.bz2 nng-959eabe2675a3b8be9bc2b2459cc899a5a64b283.zip | |
fixes #474 websocket listen on ws://*:<x> fails
fixes #464 Support NN_WS_MSG_TYPE option (compat)
fixes #415 websocket does not honor recv maxsize
This fixes a significant (and security) issue in websocket, where the
code does not honor a maximum receive size. We've exposed new API
(internal) to set the limit on the frame size, and we've changed the
default to *unlimited* for that internal API. (But the default for SP
sockets, which are the only consumers at present, is still 1MB just like
all other SP transports.)
Diffstat (limited to 'src/compat')
| -rw-r--r-- | src/compat/nanomsg/nn.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/compat/nanomsg/nn.c b/src/compat/nanomsg/nn.c index 564e60d8..bc27832e 100644 --- a/src/compat/nanomsg/nn.c +++ b/src/compat/nanomsg/nn.c @@ -749,6 +749,33 @@ nn_setignore(nng_socket s, const void *valp, size_t sz) } static int +nn_getwsmsgtype(nng_socket s, void *valp, size_t *szp) +{ + int val = NN_WS_MSG_TYPE_BINARY; + NNI_ARG_UNUSED(s); + memcpy(valp, &val, *szp < sizeof(val) ? *szp : sizeof(val)); + *szp = sizeof(val); + return (0); +} + +static int +nn_setwsmsgtype(nng_socket s, const void *valp, size_t sz) +{ + int val; + NNI_ARG_UNUSED(s); + if (sz != sizeof(val)) { + nn_seterror(NNG_EINVAL); + return (-1); + } + memcpy(&val, valp, sizeof(val)); + if (val != NN_WS_MSG_TYPE_BINARY) { + nn_seterror(NNG_EINVAL); + return (-1); + } + return (0); +} + +static int nn_settcpnodelay(nng_socket s, const void *valp, size_t sz) { bool val; @@ -1039,6 +1066,12 @@ static const struct { .nnopt = NN_TCP_NODELAY, .get = nn_gettcpnodelay, .set = nn_settcpnodelay, + }, + { + .nnlevel = NN_WS, + .nnopt = NN_WS_MSG_TYPE, + .get = nn_getwsmsgtype, + .set = nn_setwsmsgtype, } // XXX: IPV4ONLY, SNDPRIO, RCVPRIO }; |
