diff options
Diffstat (limited to 'src/libsystemd-terminal')
-rw-r--r-- | src/libsystemd-terminal/subterm.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c index 7c119ac58a..63cd2a5ad6 100644 --- a/src/libsystemd-terminal/subterm.c +++ b/src/libsystemd-terminal/subterm.c @@ -161,16 +161,14 @@ static int output_write(Output *o, const void *buf, size_t size) { _printf_(3,0) static int output_vnprintf(Output *o, size_t max, const char *format, va_list args) { - char buf[4096]; + char buf[max]; int r; assert_return(o, -EINVAL); assert_return(format, -EINVAL); - assert_return(max <= sizeof(buf), -EINVAL); + assert_return(max <= 4096, -EINVAL); - r = vsnprintf(buf, max, format, args); - if (r > (ssize_t)max) - r = max; + r = MIN(vsnprintf(buf, max, format, args), (int) max); return output_write(o, buf, r); } |