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>
Jeff King committed
Sep 24, 2015 at 17:06 UTC
f5691aa640ae2c1c5f85037e093de7f310c0eac7
1 file changed
+1
-1
progress.c
+1
-1
@@ -254,7 +254,7 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
254
throughput_string(&tp->display, tp->curr_total, rate);
255
}
256
progress_update = 1;
257
- sprintf(bufp, ", %s.\n", msg);
257
+ xsnprintf(bufp, len + 1, ", %s.\n", msg);
258
display(progress, progress->last_value, bufp);
259
if (buf != bufp)
260
free(bufp);