mirror of
git://github.com/lxc/lxc
synced 2025-08-29 19:59:51 +00:00
Merge pull request #1225 from jiazhang0/master
log: sanity check the returned value from snprintf()
This commit is contained in:
commit
aa74ed7b96
@ -170,10 +170,13 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
|
||||
event->locinfo->file, event->locinfo->func,
|
||||
event->locinfo->line);
|
||||
|
||||
n += vsnprintf(buffer + n, sizeof(buffer) - n, event->fmt,
|
||||
*event->vap);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
if (n >= sizeof(buffer) - 1) {
|
||||
if (n < sizeof(buffer) - 1)
|
||||
n += vsnprintf(buffer + n, sizeof(buffer) - n, event->fmt,
|
||||
*event->vap);
|
||||
else {
|
||||
WARN("truncated next event from %d to %zd bytes", n,
|
||||
sizeof(buffer));
|
||||
n = sizeof(buffer) - 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user