sd-device: do no allocate strings of unknown length on the stack
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 May 2021 14:49:41 +0000 (16:49 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 May 2021 15:15:04 +0000 (17:15 +0200)
commite17c95af8e450caacde692875b30675cea75211f
tree29af2769d2e882c67d9c04ed3c13c7f5cef9aba3
parent7ecb052fb3d851b8e11324b738d4c1fbe1b4ab0b
sd-device: do no allocate strings of unknown length on the stack

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33881.

Not only we would duplicate unknown input on the stack, we would do it
over and over. So let's first check that the input has reasonable length,
but also allocate just one fixed size buffer.
src/libsystemd/sd-device/sd-device.c
test/fuzz/fuzz-journald-kmsg/oss-fuzz-33881 [new file with mode: 0644]