]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: handle arbitrary line length for mounts
authorKarel Zak <kzak@redhat.com>
Thu, 27 Aug 2015 08:49:39 +0000 (10:49 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 27 Aug 2015 08:49:39 +0000 (10:49 +0200)
commitd92b8c3ba138f07a7432b367feb599141ce76121
tree0dd002d01280979b5119873378df103d0c3ab275
parent0a9e11af222dfc9455e9e6f6099e9aca4ae79ee8
libmount: handle arbitrary line length for mounts

Based on patch from Kees Cook, he wrote:
> The kernel's maximum path length is PATH_MAX (4096). The use of BUFSIZ
> (8192) would seem sufficient for reading mountinfo files, but it's
> not. Paths may contain escaped characters (requiring 4x as many bytes
> to read), and filesystem options are of unknown length. To avoid
> mounts being either intentionally or unintentionally hidden from
> libmount and its users, we must accept arbitrary length lines when
> parsing.
>
> Long valid entries are currently ignored, with warnings like this:
> mount: /proc/self/mountinfo: parse error: ignore entry at line 11.
> mount: /proc/self/mountinfo: parse error: ignore entry at line 12.
>
> Instead of using a malloc on every line parsed from mount files, do it
> once per mount file context, growing it as needed. The general case
> will never grow it.

I have moved the parser stuff to the new struct libmnt_parser, maybe
we can move more things (e.g. libmnt_table->fmt) to this struct later.

Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab_parse.c