summaryrefslogtreecommitdiff
path: root/src/trace.c
diff options
context:
space:
mode:
authorShawn Landden <shawn@git.icu>2019-05-22 10:22:43 -0500
committerShawn Landden <shawn@git.icu>2019-05-22 10:23:40 -0500
commitc4d6c62c7fdeb830521a4d51480333091f72bd03 (patch)
tree2138583cb2f4a13fdd8559299020f8119fc1dd3f /src/trace.c
parent76d8dc6c5eb65e2b3fb151db0338566f1f55dcee (diff)
downloaddistcc-git-c4d6c62c7fdeb830521a4d51480333091f72bd03.tar.gz
stats: do not crash on overflow, increase size of buffer
Closes: #341 *untested*
Diffstat (limited to 'src/trace.c')
-rw-r--r--src/trace.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/trace.c b/src/trace.c
index 8b64e29..6bb9360 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -433,9 +433,10 @@ rs_supports_trace(void)
}
-static char job_summary[4096];
+static char job_summary[4096*4];
void dcc_job_summary_clear(void) {
job_summary[0] = 0;
+ job_summary[sizeof(job_summary) - 1] = '\0';
}
void dcc_job_summary(void) {
@@ -443,5 +444,7 @@ void dcc_job_summary(void) {
}
void dcc_job_summary_append(const char *s) {
- strncat(job_summary, s, 4096-strlen(job_summary));
+ int64_t len = (4096 * 4 - 1) - strlen(job_summary);
+ if (len > 0)
+ strncat(job_summary, s, len);
}