summaryrefslogtreecommitdiff
path: root/progress.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 21:06:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-25 17:18:18 (GMT)
commitf5691aa640ae2c1c5f85037e093de7f310c0eac7 (patch)
tree7b0aace2094c7f2368d821b61b5fd5aa40d4fd49 /progress.c
parentc3bb0ac796c21490f478914441526817e4685606 (diff)
downloadgit-f5691aa640ae2c1c5f85037e093de7f310c0eac7.zip
git-f5691aa640ae2c1c5f85037e093de7f310c0eac7.tar.gz
git-f5691aa640ae2c1c5f85037e093de7f310c0eac7.tar.bz2
stop_progress_msg: convert sprintf to xsnprintf
The usual arguments for using xsnprintf over sprintf apply, but this case is a little tricky. We print to a fixed-size buffer if we have room, and otherwise to an allocated buffer. So there should be no overflow here, but it is still good to communicate our intention, as well as to check our earlier math for how much space the string will need. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'progress.c')
-rw-r--r--progress.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/progress.c b/progress.c
index a3efcfd..353bd37 100644
--- a/progress.c
+++ b/progress.c
@@ -254,7 +254,7 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
throughput_string(&tp->display, tp->curr_total, rate);
}
progress_update = 1;
- sprintf(bufp, ", %s.\n", msg);
+ xsnprintf(bufp, len + 1, ", %s.\n", msg);
display(progress, progress->last_value, bufp);
if (buf != bufp)
free(bufp);