forked from ariadne/pkgconf
fb9acedcad
It is possible to trigger an out of boundary write in function pkgconf_dependency_parse_str if a dependency line contains a very long comparator. The comparator is stored in a temporary buffer which has a size of PKGCONF_ITEM_SIZE. The line which is parsed can be up to PKGCONF_BUFSIZE characters long, which is larger than PKGCONF_ITEM_SIZE (although it depends on PATH_MAX). Having a comparator which is longer than PKGCONF_ITEM_SIZE therefore leads to an out of boundary write. Although it is undefined behaviour, this can lead to an overridden compare variable, which in turn can lead to an invalid instruction pointer, i.e. most likely a crash or code execution (very unlikely). Proof of concept: $ echo "Requires: x " > poc.pc $ dd if=/dev/zero bs=1 count=65535 | tr '\0' '<' >> poc.pc $ pkgconf poc.pc Eiter compile pkgconf with address sanitizer or run pkgconf multiple times, eventually it might crash (assuming that ASLR is in place). In order to fix this, I decided to use an end pointer to avoid OOB write. Alternative would be to increase the buffer size, but I try to avoid that since this would be additional ~60 KB stack space for a very unlikely situation. |
||
---|---|---|
.. | ||
argvsplit.c | ||
audit.c | ||
bsdstubs.c | ||
bsdstubs.h | ||
cache.c | ||
client.c | ||
config.h.meson | ||
dependency.c | ||
fileio.c | ||
fragment.c | ||
iter.h | ||
libpkgconf-api.h | ||
libpkgconf.h | ||
meson.build | ||
parser.c | ||
path.c | ||
personality.c | ||
pkg.c | ||
queue.c | ||
stdinc.h | ||
tuple.c | ||
win-dirent.h |