]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'rs/fetch-pack-invalid-lockfile'
authorJunio C Hamano <gitster@pobox.com>
Tue, 8 Dec 2020 23:11:20 +0000 (15:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Dec 2020 23:11:20 +0000 (15:11 -0800)
"fetch-pack" could pass NULL pointer to unlink(2) when it sees an
invalid filename; the error checking has been tightened to make
this impossible.

* rs/fetch-pack-invalid-lockfile:
  fetch-pack: disregard invalid pack lockfiles

fetch-pack.c

index 23179b8dd0250a700dec847d0c2916d7a8660917..876f90c759a09334bb4a47575c236d27f2887b98 100644 (file)
@@ -918,8 +918,9 @@ static int get_pack(struct fetch_pack_args *args,
        if (start_command(&cmd))
                die(_("fetch-pack: unable to fork off %s"), cmd_name);
        if (do_keep && pack_lockfiles) {
-               string_list_append_nodup(pack_lockfiles,
-                                        index_pack_lockfile(cmd.out));
+               char *pack_lockfile = index_pack_lockfile(cmd.out);
+               if (pack_lockfile)
+                       string_list_append_nodup(pack_lockfiles, pack_lockfile);
                close(cmd.out);
        }