]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap.c: avoid exposing absolute paths
authorTeng Long <dyroneteng@gmail.com>
Thu, 10 Nov 2022 07:10:12 +0000 (15:10 +0800)
committerTaylor Blau <me@ttaylorr.com>
Mon, 14 Nov 2022 22:21:16 +0000 (17:21 -0500)
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>
pack-bitmap.c
t/t5310-pack-bitmaps.sh

index 982e286bacebe73598629e4ae98e4aecd08a0b17..aaa2d9a10498a7bfd0da40b90ec8826ee6d7efcd 100644 (file)
@@ -354,8 +354,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
        if (bitmap_git->pack || bitmap_git->midx) {
                struct strbuf buf = STRBUF_INIT;
                get_midx_filename(&buf, midx->object_dir);
-               /* ignore extra bitmap file; we can only handle one */
-               warning(_("ignoring extra bitmap file: '%s'"), buf.buf);
+               trace2_data_string("bitmap", the_repository,
+                                  "ignoring extra midx bitmap file", buf.buf);
                close(fd);
                strbuf_release(&buf);
                return -1;
@@ -429,8 +429,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
        }
 
        if (bitmap_git->pack || bitmap_git->midx) {
-               /* ignore extra bitmap file; we can only handle one */
-               warning(_("ignoring extra bitmap file: '%s'"), packfile->pack_name);
+               trace2_data_string("bitmap", the_repository,
+                                  "ignoring extra bitmap file", packfile->pack_name);
                close(fd);
                return -1;
        }
@@ -455,6 +455,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
                return -1;
        }
 
+       trace2_data_string("bitmap", the_repository, "opened bitmap file",
+                          packfile->pack_name);
        return 0;
 }
 
index 6d693eef82f74a72ad4f29c399e297427c892d12..7d8dee41b0ded364d9b364ab46296c20b2c8eee1 100755 (executable)
@@ -428,8 +428,9 @@ test_bitmap_cases () {
                        test_line_count = 2 packs &&
                        test_line_count = 2 bitmaps &&
 
-                       git rev-list --use-bitmap-index HEAD 2>err &&
-                       grep "ignoring extra bitmap file" err
+                       GIT_TRACE2_EVENT=$(pwd)/trace2.txt git rev-list --use-bitmap-index HEAD &&
+                       grep "opened bitmap" trace2.txt &&
+                       grep "ignoring extra bitmap" trace2.txt
                )
        '
 }