diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-05-30 21:51:27 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-30 21:51:28 +0900 |
commit | 7c3d15fe3113cf48db60656eedd152c46f47bf6b (patch) | |
tree | afcbf8eb2ae30d903c3649aab8093a8c3a8f4b82 /log-tree.c | |
parent | Merge branch 'jk/config-blob-sans-repo' (diff) | |
parent | fmt_with_err: add a comment that truncation is OK (diff) | |
download | tgif-7c3d15fe3113cf48db60656eedd152c46f47bf6b.tar.xz |
Merge branch 'jk/snprintf-truncation'
Avoid unchecked snprintf() to make future code auditing easier.
* jk/snprintf-truncation:
fmt_with_err: add a comment that truncation is OK
shorten_unambiguous_ref: use xsnprintf
fsmonitor: use internal argv_array of struct child_process
log_write_email_headers: use strbufs
http: use strbufs instead of fixed buffers
Diffstat (limited to 'log-tree.c')
-rw-r--r-- | log-tree.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/log-tree.c b/log-tree.c index 724bae0de2..4aef85331e 100644 --- a/log-tree.c +++ b/log-tree.c @@ -387,11 +387,15 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit, graph_show_oneline(opt->graph); } if (opt->mime_boundary && maybe_multipart) { - static char subject_buffer[1024]; - static char buffer[1024]; + static struct strbuf subject_buffer = STRBUF_INIT; + static struct strbuf buffer = STRBUF_INIT; struct strbuf filename = STRBUF_INIT; *need_8bit_cte_p = -1; /* NEVER */ - snprintf(subject_buffer, sizeof(subject_buffer) - 1, + + strbuf_reset(&subject_buffer); + strbuf_reset(&buffer); + + strbuf_addf(&subject_buffer, "%s" "MIME-Version: 1.0\n" "Content-Type: multipart/mixed;" @@ -406,13 +410,13 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit, extra_headers ? extra_headers : "", mime_boundary_leader, opt->mime_boundary, mime_boundary_leader, opt->mime_boundary); - extra_headers = subject_buffer; + extra_headers = subject_buffer.buf; if (opt->numbered_files) strbuf_addf(&filename, "%d", opt->nr); else fmt_output_commit(&filename, commit, opt); - snprintf(buffer, sizeof(buffer) - 1, + strbuf_addf(&buffer, "\n--%s%s\n" "Content-Type: text/x-patch;" " name=\"%s\"\n" @@ -423,7 +427,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit, filename.buf, opt->no_inline ? "attachment" : "inline", filename.buf); - opt->diffopt.stat_sep = buffer; + opt->diffopt.stat_sep = buffer.buf; strbuf_release(&filename); } *extra_headers_p = extra_headers; |