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 <moweng.xx@antgroup.com> Signed-off-by: Teng Long <dyroneteng@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Teng Long committed
Nov 10, 2022 at 15:10 UTC
8ddc06631b184e6f43051f7ea8ac9bbc86817127
2 files changed
+9
-6
pack-bitmap.c
+6
-4
@@ -354,8 +354,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
354
if (bitmap_git->pack || bitmap_git->midx) {
355
struct strbuf buf = STRBUF_INIT;
356
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);
359
close(fd);
360
strbuf_release(&buf);
361
return -1;
@@ -429,8 +429,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
429
}
430
431
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);
434
close(fd);
435
return -1;
436
}
@@ -455,6 +455,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
455
return -1;
456
}
457
458
+ trace2_data_string("bitmap", the_repository, "opened bitmap file",
459
+ packfile->pack_name);
460
return 0;
461
}
462
t/t5310-pack-bitmaps.sh
+3
-2
@@ -428,8 +428,9 @@ test_bitmap_cases () {
428
test_line_count = 2 packs &&
429
test_line_count = 2 bitmaps &&
430
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
434
)
435
'
436
}