|
59 | 59 | FUNC(HAS_DOTGIT, WARN) \
|
60 | 60 | FUNC(NULL_SHA1, WARN) \
|
61 | 61 | FUNC(ZERO_PADDED_FILEMODE, WARN) \
|
| 62 | + FUNC(NUL_IN_COMMIT, WARN) \ |
62 | 63 | /* infos (reported as warnings, but ignored by default) */ \
|
63 | 64 | FUNC(BAD_TAG_NAME, INFO) \
|
64 | 65 | FUNC(MISSING_TAGGER_ENTRY, INFO)
|
@@ -610,6 +611,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
|
610 | 611 | struct commit_graft *graft;
|
611 | 612 | unsigned parent_count, parent_line_count = 0, author_count;
|
612 | 613 | int err;
|
| 614 | + const char *buffer_begin = buffer; |
613 | 615 |
|
614 | 616 | if (verify_headers(buffer, size, &commit->object, options))
|
615 | 617 | return -1;
|
@@ -666,9 +668,17 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
|
666 | 668 | err = fsck_ident(&buffer, &commit->object, options);
|
667 | 669 | if (err)
|
668 | 670 | return err;
|
669 |
| - if (!commit->tree) |
670 |
| - return report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1)); |
671 |
| - |
| 671 | + if (!commit->tree) { |
| 672 | + err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1)); |
| 673 | + if (err) |
| 674 | + return err; |
| 675 | + } |
| 676 | + if (memchr(buffer_begin, '\0', size)) { |
| 677 | + err = report(options, &commit->object, FSCK_MSG_NUL_IN_COMMIT, |
| 678 | + "NUL byte in the commit object body"); |
| 679 | + if (err) |
| 680 | + return err; |
| 681 | + } |
672 | 682 | return 0;
|
673 | 683 | }
|
674 | 684 |
|
|
0 commit comments