mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
shared/varlink: add missing setting of output_buffer_allocated
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14708, https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14735, https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14725, https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14720, and probably others.
This commit is contained in:
parent
21f0c55a2c
commit
be44e09162
@ -1235,15 +1235,16 @@ static int varlink_enqueue_json(Varlink *v, JsonVariant *m) {
|
||||
|
||||
} else {
|
||||
char *n;
|
||||
const size_t new_size = v->output_buffer_size + r + 1;
|
||||
|
||||
n = new(char, v->output_buffer_size + r + 1);
|
||||
n = new(char, new_size);
|
||||
if (!n)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(mempcpy(n, v->output_buffer + v->output_buffer_index, v->output_buffer_size), text, r + 1);
|
||||
|
||||
free_and_replace(v->output_buffer, n);
|
||||
v->output_buffer_size += r + 1;
|
||||
v->output_buffer_allocated = v->output_buffer_size = new_size;
|
||||
v->output_buffer_index = 0;
|
||||
}
|
||||
|
||||
|
BIN
test/fuzz/fuzz-varlink/oss-fuzz-14708
Normal file
BIN
test/fuzz/fuzz-varlink/oss-fuzz-14708
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user