Skip to content

Commit f5691aa

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3bb0ac commit f5691aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

progress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
254254
throughput_string(&tp->display, tp->curr_total, rate);
255255
}
256256
progress_update = 1;
257-
sprintf(bufp, ", %s.\n", msg);
257+
xsnprintf(bufp, len + 1, ", %s.\n", msg);
258258
display(progress, progress->last_value, bufp);
259259
if (buf != bufp)
260260
free(bufp);

0 commit comments

Comments
 (0)