Fix segfault in libwebsocket_write()
authorPavel Borzenkov <pavel.borzenkov@auriga.com>
Fri, 15 Apr 2011 12:17:26 +0000 (13:17 +0100)
committerAndy Green <andy.green@linaro.org>
Fri, 15 Apr 2011 12:17:26 +0000 (13:17 +0100)
commit4b65a562a59ce79ec03a4d1720af8eedaeca5af9
treebfa58a053acb8a331d6855b6cf8b423cb9b1b9cd
parent876534b0d5515543be72f2c92712ed841753a78f
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>
lib/parsers.c