chiark / gitweb /
shared/util: respect buffer boundary on incomplete escape sequences
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 11 Jan 2015 22:21:17 +0000 (17:21 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 12 Jan 2015 04:41:42 +0000 (23:41 -0500)
commit7f76961982e03d4d5f781e7e7113fc7eff970f82
treeb53ec520a161642ffcba434526eec371972b961d
parente01ff428993f0c126f010b5625002e6a0a8aff4a
shared/util: respect buffer boundary on incomplete escape sequences

cunescape_length_with_prefix() is called with the length as an
argument, so it cannot rely on the buffer being NUL terminated.
Move the length check before accessing the memory.

When an incomplete escape sequence was given at the end of the
buffer, c_l_w_p() would read past the end of the buffer. Fix this
and add a test.
src/shared/util.c
src/test/test-util.c