diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2017-06-22 03:10:29 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-06-22 03:10:29 +0200 |
commit | 1741b25c72c9c9b9c79d5dced98700054d52cd61 (patch) | |
tree | 82678fdbd055638f29b04caa0270bba9a2cec592 /src/basic/log.c | |
parent | only check signature job error if signature job exists (#6118) (diff) | |
download | systemd-1741b25c72c9c9b9c79d5dced98700054d52cd61.tar.xz systemd-1741b25c72c9c9b9c79d5dced98700054d52cd61.zip |
log: pass the correct length to vsnprintf (#6168)
This prevents log_object_internalv from corrupting the stack.
Closes #6147.
Many thanks to Walter Doekes for the code review.
Diffstat (limited to 'src/basic/log.c')
-rw-r--r-- | src/basic/log.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index 62c9f1a78f..e272564993 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -720,7 +720,6 @@ int log_object_internalv( PROTECT_ERRNO; char *buffer, *b; - size_t l; if (error < 0) error = -error; @@ -737,16 +736,12 @@ int log_object_internalv( size_t n; n = strlen(object); - l = n + 2 + LINE_MAX; - - buffer = newa(char, l); + buffer = newa(char, n + 2 + LINE_MAX); b = stpcpy(stpcpy(buffer, object), ": "); - } else { - l = LINE_MAX; - b = buffer = newa(char, l); - } + } else + b = buffer = newa(char, LINE_MAX); - vsnprintf(b, l, format, ap); + vsnprintf(b, LINE_MAX, format, ap); return log_dispatch_internal(level, error, file, line, func, object_field, object, extra_field, extra, buffer); |