summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-08-01tree-walk: add a strbuf wrapper for make_traverse_path()Libravatar Jeff King5-17/+32
All but one of the callers of make_traverse_path() allocate a new heap buffer to store the path. Let's give them an easy way to write to a strbuf, which saves them from computing the length themselves (which is especially tricky when they want to add to the path). It will also make it easier for us to change the make_traverse_path() interface in a future patch to improve its bounds-checking. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-01tree-walk: accept a raw length for traverse_path_len()Libravatar Jeff King3-6/+7
We take a "struct name_entry", but only care about the length of the path name. Let's just take that length directly, making it easier to use the function from callers that sometimes do not have a name_entry at all. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-01tree-walk: use size_t consistentlyLibravatar Jeff King3-8/+8
We store and manipulate the cumulative traverse_info.pathlen as an "int", which can overflow when we are fed ridiculously long pathnames (e.g., ones at the edge of 2GB or 4GB, even if the individual tree entry names are smaller than that). The results can be confusing, though after some prodding I was not able to use this integer overflow to cause an under-allocated buffer. Let's consistently use size_t to generate and store these, and make sure our addition doesn't overflow. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-31tree-walk: drop oid from traverse_infoLibravatar Jeff King5-39/+49
As the previous commit shows, the presence of an oid in each level of the traverse_info is confusing and ultimately not necessary. Let's drop it to make it clear that it will not always be set (as well as convince us that it's unused, and let the compiler catch any merges with other branches that do add new uses). Since the oid is part of name_entry, we'll actually stop embedding a name_entry entirely, and instead just separately hold the pathname, its length, and the mode. This makes the resulting code slightly more verbose as we have to pass those elements around individually. But it also makes it more clear what each code path is going to use (and in most of the paths, we really only care about the pathname itself). A few of these conversions are noisier than they need to be, as they also take the opportunity to rename "len" to "namelen" for clarity (especially where we also have "pathlen" or "ce_len" alongside). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-31setup_traverse_info(): stop copying oidLibravatar Jeff King3-7/+3
We assume that if setup_traverse_info() is passed a non-empty "base" string, that string is pointing into a tree object and we can read the object oid by skipping past the trailing NUL. As it turns out, this is not true for either of the two calls, and we may end up reading garbage bytes: 1. In git-merge-tree, our base string is either empty (in which case we'd never run this code), or it comes from our traverse_path() helper. The latter overallocates a buffer by the_hash_algo->rawsz bytes, but then fills it with only make_traverse_path(), leaving those extra bytes uninitialized (but part of a legitimate heap buffer). 2. In unpack_trees(), we pass o->prefix, which is some arbitrary string from the caller. In "git read-tree --prefix=foo", for instance, it will point to the command-line parameter, and we'll read 20 bytes past the end of the string. Interestingly, tools like ASan do not detect (2) because the process argv is part of a big pre-allocated buffer. So we're reading trash, but it's trash that's probably part of the next argument, or the environment. You can convince it to fail by putting something like this at the beginning of common-main.c's main() function: { int i; for (i = 0; i < argc; i++) argv[i] = xstrdup_or_null(argv[i]); } That puts the arguments into their own heap buffers, so running: make SANITIZE=address test will find problems when "read-tree --prefix" is used (e.g., in t3030). Doubly interesting, even with the hackery above, this does not fail prior to ea82b2a085 (tree-walk: store object_id in a separate member, 2019-01-15). That commit switched setup_traverse_info() to actually copying the hash, rather than simply pointing to it. That pointer was always pointing to garbage memory, but that commit started actually dereferencing the bytes, which is what triggers ASan. That also implies that nobody actually cares about reading these oid bytes anyway (or at least no path covered by our tests). And manual inspection of the code backs that up (I'll follow this patch with some cleanups that show definitively this is the case, but they're quite invasive, so it's worth doing this fix on its own). So let's drop the bogus hashcpy(), along with the confusing oversizing in merge-tree. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-29Merge fixes made on the 'master' frontLibravatar Junio C Hamano1-1/+72
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-29Merge branch 'jc/post-c89-rules-doc' into maintLibravatar Junio C Hamano1-3/+23
We have been trying out a few language features outside c89; the coding guidelines document did not talk about them and instead had a blanket ban against them. * jc/post-c89-rules-doc: CodingGuidelines: spell out post-C89 rules
2019-07-29Merge branch 'fc/fetch-with-import-fix' into maintLibravatar Junio C Hamano3-23/+45
Code restructuring during 2.20 period broke fetching tags via "import" based transports. * fc/fetch-with-import-fix: fetch: fix regression with transport helpers fetch: make the code more understandable fetch: trivial cleanup t5801 (remote-helpers): add test to fetch tags t5801 (remote-helpers): cleanup refspec stuff
2019-07-29Merge branch 'ds/close-object-store' into maintLibravatar Junio C Hamano19-327/+398
The commit-graph file is now part of the "files that the runtime may keep open file descriptors on, all of which would need to be closed when done with the object store", and the file descriptor to an existing commit-graph file now is closed before "gc" finalizes a new instance to replace it. * ds/close-object-store: packfile: rename close_all_packs to close_object_store packfile: close commit-graph in close_all_packs commit-graph: use raw_object_store when closing commit-graph: extract write_commit_graph_file() commit-graph: extract copy_oids_to_commits() commit-graph: extract count_distinct_commits() commit-graph: extract fill_oids_from_all_packs() commit-graph: extract fill_oids_from_commit_hex() commit-graph: extract fill_oids_from_packs() commit-graph: create write_commit_graph_context commit-graph: remove Future Work section commit-graph: collapse parameters into flags commit-graph: return with errors during write commit-graph: fix the_repository reference
2019-07-29Merge branch 'pw/add-p-recount' into maintLibravatar Junio C Hamano2-1/+13
"git checkout -p" needs to selectively apply a patch in reverse, which did not work well. * pw/add-p-recount: add -p: fix checkout -p with pathological context
2019-07-29Merge branch 'rs/avoid-overflow-in-midpoint-computation' into maintLibravatar Junio C Hamano6-7/+8
Code clean-up to avoid signed integer overlaps during binary search. * rs/avoid-overflow-in-midpoint-computation: cleanup: fix possible overflow errors in binary search, part 2
2019-07-29Merge branch 'jk/trailers-use-config' into maintLibravatar Junio C Hamano2-27/+47
"git interpret-trailers" always treated '#' as the comment character, regardless of core.commentChar setting, which has been corrected. * jk/trailers-use-config: interpret-trailers: load default config
2019-07-29Merge branch 'tg/stash-ref-by-index-fix' into maintLibravatar Junio C Hamano2-4/+23
"git stash show 23" used to work, but no more after getting rewritten in C; this regression has been corrected. * tg/stash-ref-by-index-fix: stash: fix show referencing stash index
2019-07-29Merge branch 'pw/rebase-abort-clean-rewritten' into maintLibravatar Junio C Hamano3-15/+53
"git rebase --abort" used to leave refs/rewritten/ when concluding "git rebase -r", which has been corrected. * pw/rebase-abort-clean-rewritten: rebase --abort/--quit: cleanup refs/rewritten sequencer: return errors from sequencer_remove_state() rebase: warn if state directory cannot be removed rebase: fix a memory leak
2019-07-29Merge branch 'nd/completion-no-cache-failure' into maintLibravatar Junio C Hamano1-1/+2
An incorrect list of options was cached after command line completion failed (e.g. trying to complete a command that requires a repository outside one), which has been corrected. * nd/completion-no-cache-failure: completion: do not cache if --git-completion-helper fails
2019-07-29Merge branch 'rs/config-unit-parsing' into maintLibravatar Junio C Hamano1-21/+18
The code to parse scaled numbers out of configuration files has been made more robust and also easier to follow. * rs/config-unit-parsing: config: simplify parsing of unit factors config: don't multiply in parse_unit_factor() config: use unsigned_mult_overflows to check for overflows
2019-07-29Merge branch 'jk/delta-islands-progress-fix' into maintLibravatar Junio C Hamano3-4/+5
The codepath to compute delta islands used to spew progress output without giving the callers any way to squelch it, which has been fixed. * jk/delta-islands-progress-fix: delta-islands: respect progress flag
2019-07-29Merge branch 'sg/rebase-progress' into maintLibravatar Junio C Hamano8-98/+104
Use "Erase in Line" CSI sequence that is already used in the editor support to clear cruft in the progress output. * sg/rebase-progress: progress: use term_clear_line() rebase: fix garbled progress display with '-x' pager: add a helper function to clear the last line in the terminal t3404: make the 'rebase.missingCommitsCheck=ignore' test more focused t3404: modernize here doc style
2019-07-29Merge branch 'ms/submodule-foreach-fix' into maintLibravatar Junio C Hamano2-0/+8
"git submodule foreach" did not protect command line options passed to the command to be run in each submodule correctly, when the "--recursive" option was in use. * ms/submodule-foreach-fix: submodule foreach: fix recursion of options
2019-07-29Merge branch 'js/rebase-reschedule-applies-only-to-interactive' into maintLibravatar Junio C Hamano2-3/+15
The configuration variable rebase.rescheduleFailedExec should be effective only while running an interactive rebase and should not affect anything when running an non-interactive one, which was not the case. This has been corrected. * js/rebase-reschedule-applies-only-to-interactive: rebase --am: ignore rebase.rescheduleFailedExec
2019-07-29Merge branch 'qn/clone-doc-use-long-form' into maintLibravatar Junio C Hamano1-17/+17
The "git clone" documentation refers to command line options in its description in the short form; they have been replaced with long forms to make them more recognisable. * qn/clone-doc-use-long-form: docs: git-clone: list short form of options first docs: git-clone: refer to long form of options
2019-07-29Merge branch 'jc/denoise-rm-to-resolve' into maintLibravatar Junio C Hamano2-1/+14
"git rm" to resolve a conflicted path leaked an internal message "needs merge" before actually removing the path, which was confusing. This has been corrected. * jc/denoise-rm-to-resolve: rm: resolving by removal is not a warning-worthy event
2019-07-29Merge branch 'js/mingw-spawn-with-spaces-in-path' into maintLibravatar Junio C Hamano2-3/+11
Window 7 update ;-) * js/mingw-spawn-with-spaces-in-path: mingw: support spawning programs containing spaces in their names
2019-07-29Merge branch 'sr/gpg-interface-stop-at-the-end' into maintLibravatar Junio C Hamano1-0/+3
A codepath that reads from GPG for signed object verification read past the end of allocated buffer, which has been fixed. * sr/gpg-interface-stop-at-the-end: gpg-interface: do not scan past the end of buffer
2019-07-29Merge branch 'js/clean-report-too-long-a-path' into maintLibravatar Junio C Hamano2-1/+14
"git clean" silently skipped a path when it cannot lstat() it; now it gives a warning. * js/clean-report-too-long-a-path: clean: show an error message when the path is too long
2019-07-29Merge branch 'es/local-atomic-push-failure-with-http' into maintLibravatar Junio C Hamano3-0/+69
"git push --atomic" that goes over the transport-helper (namely, the smart http transport) failed to prevent refs to be pushed when it can locally tell that one of the ref update will fail without having to consult the other end, which has been corrected. * es/local-atomic-push-failure-with-http: transport-helper: avoid var decl in for () loop control transport-helper: enforce atomic in push_refs_with_push
2019-07-29Merge branch 'po/doc-branch' into maintLibravatar Junio C Hamano2-7/+29
Doc update. * po/doc-branch: doc branch: provide examples for listing remote tracking branches
2019-07-29Merge branch 'dl/config-alias-doc' into maintLibravatar Junio C Hamano1-6/+16
Doc update. * dl/config-alias-doc: config/alias.txt: document alias accepting non-command first word config/alias.txt: change " and ' to `
2019-07-29Merge branch 'cb/fsmonitor-intfix' into maintLibravatar Junio C Hamano1-4/+4
Variable type fix. * cb/fsmonitor-intfix: fsmonitor: avoid signed integer overflow / infinite loop
2019-07-29Merge branch 'rs/copy-array' into maintLibravatar Junio C Hamano5-22/+53
Code clean-up. * rs/copy-array: use COPY_ARRAY for copying arrays coccinelle: use COPY_ARRAY for copying arrays
2019-07-29Merge branch 'js/t3404-typofix' into maintLibravatar Junio C Hamano1-1/+1
Typofix. * js/t3404-typofix: t3404: fix a typo
2019-07-29Merge branch 'cb/mkstemps-uint-type-fix' into maintLibravatar Junio C Hamano1-1/+1
Variable type fix. * cb/mkstemps-uint-type-fix: wrapper: avoid undefined behaviour in macOS
2019-07-29Merge branch 'js/t0001-case-insensitive' into maintLibravatar Junio C Hamano2-14/+23
Test update. * js/t0001-case-insensitive: t0001: fix on case-insensitive filesystems
2019-07-29Merge branch 'jw/gitweb-sample-update' into maintLibravatar Junio C Hamano1-2/+1
Doc update. * jw/gitweb-sample-update: doc: don't use git.kernel.org as example gitweb URL
2019-07-29Merge branch 'sg/t5551-fetch-smart-error-is-translated' into maintLibravatar Junio C Hamano1-2/+2
Test update. * sg/t5551-fetch-smart-error-is-translated: t5551: use 'test_i18ngrep' to check translated output
2019-07-29Merge branch 'jt/t5551-test-chunked' into maintLibravatar Junio C Hamano1-3/+2
Update smart-http test. * jt/t5551-test-chunked: t5551: test usage of chunked encoding explicitly
2019-07-29Merge branch 'sg/git-C-empty-doc' into maintLibravatar Junio C Hamano1-1/+2
Doc update. * sg/git-C-empty-doc: Document that 'git -C ""' works and doesn't change directory
2019-07-29Merge branch 'sg/ci-brew-gcc-workaround' into maintLibravatar Junio C Hamano2-3/+5
Dev support update. * sg/ci-brew-gcc-workaround: ci/lib.sh: update a comment about installed P4 and Git-LFS versions ci: disable Homebrew's auto cleanup ci: don't update Homebrew
2019-07-29Merge branch 'js/trace2-signo-typofix' into maintLibravatar Junio C Hamano1-1/+1
Documentation fix. * js/trace2-signo-typofix: trace2: correct trace2 field name documentation
2019-07-29Merge branch 'di/readme-markup-fix' into maintLibravatar Junio C Hamano1-1/+1
Docfix. * di/readme-markup-fix: README: fix rendering of text in angle brackets
2019-07-29Merge branch 'vn/xmmap-gently' into maintLibravatar Junio C Hamano1-1/+1
Clean-up an error codepath. * vn/xmmap-gently: read-cache.c: do not die if mmap fails
2019-07-29Merge branch 'rm/gpg-program-doc-fix' into maintLibravatar Junio C Hamano1-1/+1
Docfix. * rm/gpg-program-doc-fix: gpg(docs): use correct --verify syntax
2019-07-29Merge branch 'js/unmap-before-ext-diff' into maintLibravatar Junio C Hamano1-0/+2
Windows update. * js/unmap-before-ext-diff: diff: munmap() file contents before running external diff
2019-07-29Merge branch 'js/gcc-8-and-9' into maintLibravatar Junio C Hamano4-13/+15
Code clean-up for new compilers. The 'kwset' one may get a wholesale replacement, either with new version of kwset from upstream or removal of its users, but in the meantime, it is probably OK to merge it down. * js/gcc-8-and-9: config: avoid calling `labs()` on too-large data type winansi: simplify loading the GetCurrentConsoleFontEx() function kwset: allow building with GCC 8 poll (mingw): allow compiling with GCC 8 and DEVELOPER=1
2019-07-25Flush fixes up to the third batch post 2.22.0Libravatar Junio C Hamano2-1/+77
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-25Merge branch 'ab/hash-object-doc' into maintLibravatar Junio C Hamano1-3/+1
Doc update. * ab/hash-object-doc: hash-object doc: stop mentioning git-cvsimport
2019-07-25Merge branch 'cm/send-email-document-req-modules' into maintLibravatar Junio C Hamano1-2/+6
A doc update. * cm/send-email-document-req-modules: send-email: update documentation of required Perl modules
2019-07-25Merge branch 'sw/git-p4-unshelve-branched-files' into maintLibravatar Junio C Hamano2-2/+8
"git p4" update. * sw/git-p4-unshelve-branched-files: git-p4: allow unshelving of branched files
2019-07-25Merge branch 'js/bisect-helper-check-get-oid-return-value' into maintLibravatar Junio C Hamano1-1/+4
Code cleanup. * js/bisect-helper-check-get-oid-return-value: bisect--helper: verify HEAD could be parsed before continuing
2019-07-25Merge branch 'es/git-debugger-doc' into maintLibravatar Junio C Hamano1-0/+6
Doc update. * es/git-debugger-doc: doc: hint about GIT_DEBUGGER in CodingGuidelines