Commit Graph

9892 Commits

Author SHA1 Message Date
Patrick Steinhardt
7d02019a07 transports: smart: fix potential invalid memory dereferences
When we receive a packet of exactly four bytes encoding its
length as those four bytes it can be treated as an empty line.
While it is not really specified how those empty lines should be
treated, we currently ignore them and do not return an error when
trying to parse it but simply advance the data pointer.

Callers invoking `git_pkt_parse_line` are currently not prepared
to handle this case as they do not explicitly check this case.
While they could always reset the passed out-pointer to `NULL`
before calling `git_pkt_parse_line` and determine if the pointer
has been set afterwards, it makes more sense to update
`git_pkt_parse_line` to set the out-pointer to `NULL` itself when
it encounters such an empty packet. Like this it is guaranteed
that there will be no invalid memory references to free'd
pointers.

As such, the issue has been fixed such that `git_pkt_parse_line`
always sets the packet out pointer to `NULL` when an empty packet
has been received and callers check for this condition, skipping
such packets.
2016-06-07 09:14:14 +02:00
Edward Thomson
f0ee795ccb Merge pull request #3808 from ethomson/read_index_fixes
`git_index_read_index` fixes
2016-06-02 03:08:26 -05:00
Edward Thomson
46082c384f index_read_index: invalidate new paths in tree cache
When adding a new entry to an existing index via `git_index_read_index`,
be sure to remove the tree cache entry for that new path.  This will
mark all parent trees as dirty.
2016-06-02 02:38:55 -05:00
Edward Thomson
5acf18ac63 rebase: test rebasing a new commit with subfolder
Test a rebase (both a merge rebase and an inmemory rebase) with a new
commit that adds files underneath a new subfolder.
2016-06-02 02:38:18 -05:00
Edward Thomson
91fbf9d867 test: ensure we can round-trip a written tree
Read a tree into an index, write the index, then re-open the index and
ensure that we are treesame to the original.
2016-06-02 02:37:04 -05:00
Edward Thomson
9167c1450e index_read_index: set flags for path_len correctly
Update the flags to reset the path_len (to emulate `index_insert`)
2016-06-02 02:36:50 -05:00
Edward Thomson
046ec3c9d6 index_read_index: differentiate on mode
Treat index entries with different modes as different, which they
are, at least for the purposes of up-to-date calculations.
2016-06-02 02:36:46 -05:00
Edward Thomson
93de20b8d2 index_read_index: reset error correctly
Clear any error state upon each iteration.  If one of the iterations
ends (with an error of `GIT_ITEROVER`) we need to reset that error to 0,
lest we stop the whole process prematurely.
2016-06-02 02:36:44 -05:00
Edward Thomson
5baa20b86e round-trip trees through index_read_index
Read a tree into an index using `git_index_read_index` (by reading
a tree into a new index, then reading that index into the current
index), then write the index back out, ensuring that our new index
is treesame to the tree that we read.
2016-06-02 00:59:46 -05:00
Edward Thomson
0aaba44593 Merge pull request #3796 from mmuman/haiku
Preliminary Haiku port
2016-06-01 11:33:58 -05:00
Edward Thomson
efb432c9b9 Merge pull request #3801 from ethomson/warning
cleanup: unused warning
2016-06-01 11:05:45 -05:00
Edward Thomson
14cf05dae8 win32: clean up unused warnings in DllMain 2016-06-01 10:03:52 -05:00
Edward Thomson
4505a42a23 rebase: change assertion to avoid
It looks like we're getting the operation and not doing anything
with it, when in fact we are asserting that it's not null.  Simply
assert that we are within the operation boundary instead of using
the `git_array_get` macro to do this for us.
2016-06-01 10:03:52 -05:00
Edward Thomson
e3c42fee77 filebuf: fix uninitialized warning 2016-06-01 10:03:52 -05:00
Edward Thomson
0d77a56f39 checkout: drop unused repo 2016-06-01 10:03:51 -05:00
Edward Thomson
c2f18b9b06 cleanup: unused warning 2016-06-01 10:03:51 -05:00
Edward Thomson
37dba1a739 Merge pull request #3803 from glensc/patch-1
Update CMakeLists.txt
2016-05-27 09:15:01 -05:00
Elan Ruusamäe
13b0b7d520 Update CMakeLists.txt
typo fix
2016-05-27 10:20:35 +03:00
Edward Thomson
853e585fb1 patch: zero id and abbrev length for empty files 2016-05-26 13:01:09 -05:00
Edward Thomson
33ae876239 patch: identify non-binary patches as NOT_BINARY 2016-05-26 13:01:09 -05:00
Edward Thomson
728274904f Introduce git_diff_to_buf
Like `git_patch_to_buf`, provide a simple helper method that can
print an entire diff directory to a `git_buf`.
2016-05-26 13:01:09 -05:00
Edward Thomson
7166bb1665 introduce git_diff_from_buffer to parse diffs
Parse diff files into a `git_diff` structure.
2016-05-26 13:01:09 -05:00
Edward Thomson
94e488a056 patch: differentiate not found and invalid patches 2016-05-26 13:01:08 -05:00
Edward Thomson
17572f67ed git_patch_parse_ctx: refcount the context 2016-05-26 13:01:08 -05:00
Edward Thomson
9be638ecf0 git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
Edward Thomson
aa4bfb32b9 parse: introduce parse_ctx_contains_s 2016-05-26 13:01:08 -05:00
Edward Thomson
8d44f8b78f patch: patch_diff -> patch_generated 2016-05-26 13:01:08 -05:00
Edward Thomson
53571f2f0c vector: more sensible names for grow_at/shrink_at 2016-05-26 13:01:08 -05:00
Edward Thomson
440e3bae10 patch: git_patch_from_patchfile -> git_patch_from_buffer 2016-05-26 13:01:08 -05:00
Edward Thomson
00e63b3620 patch: provide static string advance_expected 2016-05-26 13:01:07 -05:00
Edward Thomson
a03952f095 patch: formatting cleanups 2016-05-26 13:01:07 -05:00
Edward Thomson
e564fc65b5 git_vector_grow/shrink: correct shrink, and tests 2016-05-26 13:01:07 -05:00
Edward Thomson
0ff723cc90 apply: test postimages that grow/shrink original
Test with some postimages that actually grow/shrink from the
original, adding new lines or removing them.  (Also do so without
context to ensure that we can add/remove from a non-zero part of
the line vector.)
2016-05-26 13:01:07 -05:00
Edward Thomson
8cb27223b8 git_buf_quote/unquote: handle > \177
Parse values up to and including `\377` (`0xff`) when unquoting.
Print octal values as an unsigned char when quoting, lest `printf`
think we're talking about negatives.
2016-05-26 13:01:07 -05:00
Edward Thomson
0267c34c0c patch application: drop unnecessary patch_image_init 2016-05-26 13:01:07 -05:00
Edward Thomson
4117a2350f patch parse: dup the patch from the callers 2016-05-26 13:01:07 -05:00
Edward Thomson
6278fbc5dd patch parsing: squash some memory leaks 2016-05-26 13:01:07 -05:00
Edward Thomson
f941f035ae patch: drop some warnings 2016-05-26 13:01:06 -05:00
Edward Thomson
040ec883a4 patch: use strlen to mean string length
`oid_strlen` has meant one more than the length of the string.
This is mighty confusing.  Make it mean only the string length!
Whomsoever needs to allocate a buffer to hold a string can null
terminate it like normal.
2016-05-26 13:01:06 -05:00
Edward Thomson
e2cdc145b9 patch: show modes when only the mode has changed 2016-05-26 13:01:06 -05:00
Edward Thomson
4ac2d8acf4 patch: quote filenames when necessary 2016-05-26 13:01:06 -05:00
Edward Thomson
d3d95d5ae2 git_buf_quote: quote ugly characters 2016-05-26 13:01:06 -05:00
Edward Thomson
72806f4cca patch: don't print some headers on pure renames 2016-05-26 13:01:06 -05:00
Edward Thomson
82175084e1 Introduce git_patch_options, handle prefixes
Handle prefixes (in terms of number of path components) for patch
parsing.
2016-05-26 13:01:06 -05:00
Edward Thomson
19e46645af patch printing: include rename information 2016-05-26 13:01:06 -05:00
Edward Thomson
d536ceacf5 patch_parse: don't set new mode when deleted 2016-05-26 13:01:05 -05:00
Edward Thomson
28f704433b patch_parse: use names from diff --git header
When a text file is added or deleted, use the file names from the
`diff --git` header instead of the `---` or `+++` lines.  This is
for compatibility with git.
2016-05-26 13:01:05 -05:00
Edward Thomson
1462c95a5d patch_parse: set binary flag
We may have parsed binary data, set the `SHOW_BINARY` flag which
indicates that we have actually computed a binary diff.
2016-05-26 13:01:05 -05:00
Edward Thomson
2f3b922ff1 patch_parse: test roundtrip patch parsing -> print 2016-05-26 13:01:05 -05:00
Edward Thomson
42b3442823 patch_parse: ensure we can parse a patch 2016-05-26 13:01:05 -05:00