lws_snprintf
authorAndy Green <andy@warmcat.com>
Wed, 14 Sep 2016 18:36:22 +0000 (02:36 +0800)
committerAndy Green <andy@warmcat.com>
Wed, 14 Sep 2016 18:36:22 +0000 (02:36 +0800)
commit151aa809a6110c0226ae0a27f1567e42f502ae96
treee085811fb5014eb2436811b59924435e0f456619
parent8d4c673d02624b5da82cea29b6370c0b6e23d444
lws_snprintf

Thanks to Fabrice Gilot for reporting the problem that led to uncovering this.

Due to a misunderstanding of the return value of snprintf (it is not truncated according
to the max size passed in) in places relying on snprintf to truncate the length
overflows are possible.

This patch wraps snprintf with a new lws_snprintf() which does truncate its length to allow
the buffer limiting scheme to work properly.

All users should update with these fixes.

In 1.7.x, there's no affected code in the library itself, just a couple on instances in the
test app code.
lib/libwebsockets.c
lib/libwebsockets.h
lib/private-libwebsockets.h
test-server/test-fraggle.c
test-server/test-ping.c
test-server/test-server-status.c