test-ellipsize: add tests for ellipsize_mem, fix bugs
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 2 Jun 2018 15:08:46 +0000 (17:08 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 2 Jun 2018 19:53:25 +0000 (21:53 +0200)
commit9924aef690ad20f35c5391aad7fd7c5a9576cc21
tree42a9f34dbd5a9bdaec5e5892e09eb289f5229d79
parentae03775f56033377138a70dc3d76acfd6a88a7de
test-ellipsize: add tests for ellipsize_mem, fix bugs

First, ellipsize() and ellipsize_mem() should not read past the input
buffer. Those functions take an explicit length for the input data, so they
should not assume that the buffer is terminated by a nul.

Second, ellipsization was off in various cases where wide on multi-byte
characters were used.

We had some basic test for ellipsize(), but apparently it wasn't enough to
catch more serious cases.

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8686.
src/basic/string-util.c
src/test/test-ellipsize.c
src/test/test-string-util.c
test/fuzz-regressions/fuzz-journal-remote/oss-fuzz-8686 [new file with mode: 0644]