Skip to content

Commit 7913f53

Browse files
committed
Sync with Git 2.17.1
* maint: (25 commits) Git 2.17.1 Git 2.16.4 Git 2.15.2 Git 2.14.4 Git 2.13.7 fsck: complain when .gitmodules is a symlink index-pack: check .gitmodules files with --strict unpack-objects: call fsck_finish() after fscking objects fsck: call fsck_finish() after fscking objects fsck: check .gitmodules content fsck: handle promisor objects in .gitmodules check fsck: detect gitmodules files fsck: actually fsck blob data fsck: simplify ".git" check index-pack: make fsck error message more specific verify_path: disallow symlinks in .gitmodules update-index: stat updated files earlier verify_dotfile: mention case-insensitivity in comment verify_path: drop clever fallthrough skip_prefix: add case-insensitive variant ...
2 parents e144d12 + fc54c1a commit 7913f53

28 files changed

+794
-72
lines changed

Documentation/RelNotes/2.13.7.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Git v2.13.7 Release Notes
2+
=========================
3+
4+
Fixes since v2.13.6
5+
-------------------
6+
7+
* Submodule "names" come from the untrusted .gitmodules file, but we
8+
blindly append them to $GIT_DIR/modules to create our on-disk repo
9+
paths. This means you can do bad things by putting "../" into the
10+
name. We now enforce some rules for submodule names which will cause
11+
Git to ignore these malicious names (CVE-2018-11235).
12+
13+
Credit for finding this vulnerability and the proof of concept from
14+
which the test script was adapted goes to Etienne Stalmans.
15+
16+
* It was possible to trick the code that sanity-checks paths on NTFS
17+
into reading random piece of memory (CVE-2018-11233).
18+
19+
Credit for fixing for these bugs goes to Jeff King, Johannes
20+
Schindelin and others.

Documentation/RelNotes/2.14.4.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.14.4 Release Notes
2+
=========================
3+
4+
This release is to forward-port the fixes made in the v2.13.7 version
5+
of Git. See its release notes for details.

Documentation/RelNotes/2.15.2.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@ Fixes since v2.15.1
4343
* Clarify and enhance documentation for "merge-base --fork-point", as
4444
it was clear what it computed but not why/what for.
4545

46+
* This release also contains the fixes made in the v2.13.7 version of
47+
Git. See its release notes for details.
48+
4649

4750
Also contains various documentation updates and code clean-ups.

Documentation/RelNotes/2.16.4.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.16.4 Release Notes
2+
=========================
3+
4+
This release is to forward-port the fixes made in the v2.13.7 version
5+
of Git. See its release notes for details.

Documentation/RelNotes/2.17.1.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Git v2.17.1 Release Notes
2+
=========================
3+
4+
Fixes since v2.17
5+
-----------------
6+
7+
* This release contains the same fixes made in the v2.13.7 version of
8+
Git, covering CVE-2018-11233 and 11235, and forward-ported to
9+
v2.14.4, v2.15.2 and v2.16.4 releases. See release notes to
10+
v2.13.7 for details.
11+
12+
* In addition to the above fixes, this release has support on the
13+
server side to reject pushes to repositories that attempt to create
14+
such problematic .gitmodules file etc. as tracked contents, to help
15+
hosting sites protect their customers by preventing malicious
16+
contents from spreading.

apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,9 +3860,9 @@ static int check_unsafe_path(struct patch *patch)
38603860
if (!patch->is_delete)
38613861
new_name = patch->new_name;
38623862

3863-
if (old_name && !verify_path(old_name))
3863+
if (old_name && !verify_path(old_name, patch->old_mode))
38643864
return error(_("invalid path '%s'"), old_name);
3865-
if (new_name && !verify_path(new_name))
3865+
if (new_name && !verify_path(new_name, patch->new_mode))
38663866
return error(_("invalid path '%s'"), new_name);
38673867
return 0;
38683868
}

builtin/fsck.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static void check_connectivity(void)
340340
}
341341
}
342342

343-
static int fsck_obj(struct object *obj)
343+
static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
344344
{
345345
int err;
346346

@@ -354,7 +354,7 @@ static int fsck_obj(struct object *obj)
354354

355355
if (fsck_walk(obj, NULL, &fsck_obj_options))
356356
objerror(obj, "broken links");
357-
err = fsck_object(obj, NULL, 0, &fsck_obj_options);
357+
err = fsck_object(obj, buffer, size, &fsck_obj_options);
358358
if (err)
359359
goto out;
360360

@@ -399,7 +399,7 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
399399
}
400400
obj->flags &= ~(REACHABLE | SEEN);
401401
obj->flags |= HAS_OBJ;
402-
return fsck_obj(obj);
402+
return fsck_obj(obj, buffer, size);
403403
}
404404

405405
static int default_refs;
@@ -507,44 +507,42 @@ static void get_default_heads(void)
507507
}
508508
}
509509

510-
static struct object *parse_loose_object(const struct object_id *oid,
511-
const char *path)
510+
static int fsck_loose(const struct object_id *oid, const char *path, void *data)
512511
{
513512
struct object *obj;
514-
void *contents;
515513
enum object_type type;
516514
unsigned long size;
515+
void *contents;
517516
int eaten;
518517

519-
if (read_loose_object(path, oid, &type, &size, &contents) < 0)
520-
return NULL;
518+
if (read_loose_object(path, oid, &type, &size, &contents) < 0) {
519+
errors_found |= ERROR_OBJECT;
520+
error("%s: object corrupt or missing: %s",
521+
oid_to_hex(oid), path);
522+
return 0; /* keep checking other objects */
523+
}
521524

522525
if (!contents && type != OBJ_BLOB)
523-
die("BUG: read_loose_object streamed a non-blob");
526+
BUG("read_loose_object streamed a non-blob");
524527

525528
obj = parse_object_buffer(oid, type, size, contents, &eaten);
526-
527-
if (!eaten)
528-
free(contents);
529-
return obj;
530-
}
531-
532-
static int fsck_loose(const struct object_id *oid, const char *path, void *data)
533-
{
534-
struct object *obj = parse_loose_object(oid, path);
535-
536529
if (!obj) {
537530
errors_found |= ERROR_OBJECT;
538-
error("%s: object corrupt or missing: %s",
531+
error("%s: object could not be parsed: %s",
539532
oid_to_hex(oid), path);
533+
if (!eaten)
534+
free(contents);
540535
return 0; /* keep checking other objects */
541536
}
542537

543538
obj->flags &= ~(REACHABLE | SEEN);
544539
obj->flags |= HAS_OBJ;
545-
if (fsck_obj(obj))
540+
if (fsck_obj(obj, contents, size))
546541
errors_found |= ERROR_OBJECT;
547-
return 0;
542+
543+
if (!eaten)
544+
free(contents);
545+
return 0; /* keep checking other objects, even if we saw an error */
548546
}
549547

550548
static int fsck_cruft(const char *basename, const char *path, void *data)
@@ -756,6 +754,9 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
756754
}
757755
stop_progress(&progress);
758756
}
757+
758+
if (fsck_finish(&fsck_obj_options))
759+
errors_found |= ERROR_OBJECT;
759760
}
760761

761762
for (i = 0; i < argc; i++) {

builtin/index-pack.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,9 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
837837
blob->object.flags |= FLAG_CHECKED;
838838
else
839839
die(_("invalid blob object %s"), oid_to_hex(oid));
840+
if (do_fsck_object &&
841+
fsck_object(&blob->object, (void *)data, size, &fsck_options))
842+
die(_("fsck error in packed object"));
840843
} else {
841844
struct object *obj;
842845
int eaten;
@@ -854,7 +857,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
854857
die(_("invalid %s"), type_name(type));
855858
if (do_fsck_object &&
856859
fsck_object(obj, buf, size, &fsck_options))
857-
die(_("Error in object"));
860+
die(_("fsck error in packed object"));
858861
if (strict && fsck_walk(obj, NULL, &fsck_options))
859862
die(_("Not all child objects of %s are reachable"), oid_to_hex(&obj->oid));
860863

@@ -1479,6 +1482,9 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
14791482
} else
14801483
chmod(final_index_name, 0444);
14811484

1485+
if (do_fsck_object)
1486+
add_packed_git(final_index_name, strlen(final_index_name), 0);
1487+
14821488
if (!from_stdin) {
14831489
printf("%s\n", sha1_to_hex(hash));
14841490
} else {
@@ -1820,6 +1826,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
18201826
pack_hash);
18211827
else
18221828
close(input_fd);
1829+
1830+
if (do_fsck_object && fsck_finish(&fsck_options))
1831+
die(_("fsck error in pack objects"));
1832+
18231833
free(objects);
18241834
strbuf_release(&index_name_buf);
18251835
if (pack_name == NULL)

builtin/submodule--helper.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,29 @@ static int is_active(int argc, const char **argv, const char *prefix)
18251825
return !is_submodule_active(the_repository, argv[1]);
18261826
}
18271827

1828+
/*
1829+
* Exit non-zero if any of the submodule names given on the command line is
1830+
* invalid. If no names are given, filter stdin to print only valid names
1831+
* (which is primarily intended for testing).
1832+
*/
1833+
static int check_name(int argc, const char **argv, const char *prefix)
1834+
{
1835+
if (argc > 1) {
1836+
while (*++argv) {
1837+
if (check_submodule_name(*argv) < 0)
1838+
return 1;
1839+
}
1840+
} else {
1841+
struct strbuf buf = STRBUF_INIT;
1842+
while (strbuf_getline(&buf, stdin) != EOF) {
1843+
if (!check_submodule_name(buf.buf))
1844+
printf("%s\n", buf.buf);
1845+
}
1846+
strbuf_release(&buf);
1847+
}
1848+
return 0;
1849+
}
1850+
18281851
#define SUPPORT_SUPER_PREFIX (1<<0)
18291852

18301853
struct cmd_struct {
@@ -1850,6 +1873,7 @@ static struct cmd_struct commands[] = {
18501873
{"push-check", push_check, 0},
18511874
{"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX},
18521875
{"is-active", is_active, 0},
1876+
{"check-name", check_name, 0},
18531877
};
18541878

18551879
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)

builtin/unpack-objects.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op
210210
if (!obj_buf)
211211
die("Whoops! Cannot find object '%s'", oid_to_hex(&obj->oid));
212212
if (fsck_object(obj, obj_buf->buffer, obj_buf->size, &fsck_options))
213-
die("Error in object");
213+
die("fsck error in packed object");
214214
fsck_options.walk = check_object;
215215
if (fsck_walk(obj, NULL, &fsck_options))
216216
die("Error on reachable objects of %s", oid_to_hex(&obj->oid));
@@ -572,8 +572,11 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
572572
unpack_all();
573573
the_hash_algo->update_fn(&ctx, buffer, offset);
574574
the_hash_algo->final_fn(oid.hash, &ctx);
575-
if (strict)
575+
if (strict) {
576576
write_rest();
577+
if (fsck_finish(&fsck_options))
578+
die(_("fsck error in pack objects"));
579+
}
577580
if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
578581
die("final sha1 did not match");
579582
use(the_hash_algo->rawsz);

0 commit comments

Comments
 (0)