1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Fix segfault in libwebsocket_write()

Since 'shift' has unsigned integer type,
the following code may lead to infinite cycle
and segfault:

    while (shift >= 0) {
    	if (shift)
    		buf[0 - pre + n] =
    			((len >> shift) & 127) | 0x80;
    	else
    		buf[0 - pre + n] =
    			((len >> shift) & 127);
    	n++;
    	shift -= 7;
    }

Change type to signed integer.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@auriga.com>
This commit is contained in:
Pavel Borzenkov 2011-04-15 13:17:26 +01:00 committed by Andy Green
parent 876534b0d5
commit 4b65a562a5

View file

@ -1115,7 +1115,7 @@ int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
int m;
int pre = 0;
int post = 0;
unsigned int shift = 7;
int shift = 7;
struct lws_tokens eff_buf;
int ret;