]> git.ipfire.org Git - thirdparty/util-linux.git/commit
ul: Fix buffer overflow
authorTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 8 Sep 2016 19:19:22 +0000 (21:19 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 29 Sep 2016 09:49:08 +0000 (11:49 +0200)
commitf20b214edc6e0c422a9a8991929fb793ee543dda
tree2069785c72d4a78280c31c6cd212efb4abc99047
parent0b404f0845fe97f84e45f9b7b23e9e1814d3ef4e
ul: Fix buffer overflow

The text-utility ul can run into a buffer overflow on very long lines.
See this proof of concept how to reproduce the issue:

$ dd if=/dev/zero bs=1M count=10 | tr '\000' '\041' > poc.txt
$ echo -ne '\xe\x5f\x8\x5f\x61\x2\xf\x5f\x8\x5f' | dd of=poc.txt conv=notrunc
$ ul -i poc.txt > /dev/null # output would take ages
Segmentation fault
$ _

The problem manifests by using alloca with "maxcol", which can be as
large as INT_MAX, based on the input line.

A very long line (> 8 MB) with modes must be supplied to ul, as seen in
my proof of concept byte sequence above.

It is rather easy to fix this issue: allocate space on the heap instead.
maxcol could overflow here, but in that case no system will have enough
space to handle the request, properly ending ul through an err() call.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
text-utils/ul.c