From 397b7056471f5644e1d9ad32426a2789b96d43d7 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 9 Apr 2016 12:29:18 +0300 Subject: [PATCH] extmod/modwebsocket: Reset mask between packets. --- extmod/modwebsocket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c index 9f4e5ee7e8..6cd4f515df 100644 --- a/extmod/modwebsocket.c +++ b/extmod/modwebsocket.c @@ -82,6 +82,11 @@ STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int switch (self->state) { case FRAME_HEADER: { assert(self->buf[0] & 0x80); + + // Reset mask in case someone will use "simplified" protocol + // without masks. + memset(self->mask, 0, sizeof(self->mask)); + int to_recv = 0; size_t sz = self->buf[1] & 0x7f; if (sz == 126) {