Skip to content

Commit

Permalink
stop_progress_msg: convert sprintf to xsnprintf
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
peff authored and gitster committed Sep 25, 2015
1 parent c3bb0ac commit f5691aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f5691aa

Please sign in to comment.