Skip to content

Commit 8c5acfb

Browse files
peffgitster
authored andcommitted
transport-helper: replace checked snprintf with xsnprintf
We can use xsnprintf to do our truncation check with less code. The error message isn't as specific, but the point is that this isn't supposed to trigger in the first place (because our buffer is big enough to handle any int). Signed-off-by: Jeff King <[email protected]>
1 parent 1a168e5 commit 8c5acfb

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

transport-helper.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,11 @@ static int set_helper_option(struct transport *transport,
347347
static void standard_options(struct transport *t)
348348
{
349349
char buf[16];
350-
int n;
351350
int v = t->verbose;
352351

353352
set_helper_option(t, "progress", t->progress ? "true" : "false");
354353

355-
n = snprintf(buf, sizeof(buf), "%d", v + 1);
356-
if (n >= sizeof(buf))
357-
die("impossibly large verbosity value");
354+
xsnprintf(buf, sizeof(buf), "%d", v + 1);
358355
set_helper_option(t, "verbosity", buf);
359356

360357
switch (t->family) {

0 commit comments

Comments
 (0)