When the debug mode is enabled, the vlog function formats a log message
in a stack-allocated buffer using vsnprintf and assumes that the
returned value represents the number of written bytes. This is an
incorrect assumption if the message is larger than the buffer
size (minus one) since the return value tells how many bytes *would*
have been written.
* Fixed crash when the debug mode is enabled and the output file is in a
non-writable directory, e.g. when the output file is `/dev/null`.
+* Fixed an issue when printing very large log messages to the debug log.
+
ccache 3.6
----------
// Copyright (C) 2002 Andrew Tridgell
-// Copyright (C) 2009-2018 Joel Rosdahl
+// Copyright (C) 2009-2019 Joel Rosdahl
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
}
if (logbuffer) {
char buf[1024];
- size_t len = vsnprintf(buf, sizeof(buf), format, aq);
- append_log(buf, len);
- append_log("\n", 1);
+ int len = vsnprintf(buf, sizeof(buf), format, aq);
+ if (len >= 0) {
+ append_log(buf, MIN((size_t)len, sizeof(buf) - 1));
+ append_log("\n", 1);
+ }
}
va_end(aq);
}