Skip to content

Commit 8ddc066

Browse files
dyronettaylorr
authored andcommitted
pack-bitmap.c: avoid exposing absolute paths
In "open_midx_bitmap_1()" and "open_pack_bitmap_1()", when we find that there are multiple bitmaps, we will only open the first one and then leave warnings about the remaining pack information, the information will contain the absolute path of the repository, for example in a alternates usage scenario. So let's hide this kind of potentially sensitive information in this commit. Found-by: XingXin <[email protected]> Signed-off-by: Teng Long <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 2aa84d5 commit 8ddc066

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pack-bitmap.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
354354
if (bitmap_git->pack || bitmap_git->midx) {
355355
struct strbuf buf = STRBUF_INIT;
356356
get_midx_filename(&buf, midx->object_dir);
357-
/* ignore extra bitmap file; we can only handle one */
358-
warning(_("ignoring extra bitmap file: '%s'"), buf.buf);
357+
trace2_data_string("bitmap", the_repository,
358+
"ignoring extra midx bitmap file", buf.buf);
359359
close(fd);
360360
strbuf_release(&buf);
361361
return -1;
@@ -429,8 +429,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
429429
}
430430

431431
if (bitmap_git->pack || bitmap_git->midx) {
432-
/* ignore extra bitmap file; we can only handle one */
433-
warning(_("ignoring extra bitmap file: '%s'"), packfile->pack_name);
432+
trace2_data_string("bitmap", the_repository,
433+
"ignoring extra bitmap file", packfile->pack_name);
434434
close(fd);
435435
return -1;
436436
}
@@ -455,6 +455,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
455455
return -1;
456456
}
457457

458+
trace2_data_string("bitmap", the_repository, "opened bitmap file",
459+
packfile->pack_name);
458460
return 0;
459461
}
460462

t/t5310-pack-bitmaps.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ test_bitmap_cases () {
428428
test_line_count = 2 packs &&
429429
test_line_count = 2 bitmaps &&
430430
431-
git rev-list --use-bitmap-index HEAD 2>err &&
432-
grep "ignoring extra bitmap file" err
431+
GIT_TRACE2_EVENT=$(pwd)/trace2.txt git rev-list --use-bitmap-index HEAD &&
432+
grep "opened bitmap" trace2.txt &&
433+
grep "ignoring extra bitmap" trace2.txt
433434
)
434435
'
435436
}

0 commit comments

Comments
 (0)