Skip to content

Commit 68a423a

Browse files
peffgitster
authored andcommitted
get-tar-commit-id: check write_in_full() return against 0
We ask to write 41 bytes and make sure that the return value is at least 41. This is the same "dangerous" pattern that was fixed in the prior commit (wherein a negative return value is promoted to unsigned), though it is not dangerous here because our "41" is a constant, not an unsigned variable. But we should convert it anyway to avoid modeling a dangerous construct. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent efacf60 commit 68a423a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

builtin/get-tar-commit-id.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
3333
if (!skip_prefix(content, "52 comment=", &comment))
3434
return 1;
3535

36-
n = write_in_full(1, comment, 41);
37-
if (n < 41)
36+
if (write_in_full(1, comment, 41) < 0)
3837
die_errno("git get-tar-commit-id: write error");
3938

4039
return 0;

0 commit comments

Comments
 (0)