Commit Graph

5935 Commits

Author SHA1 Message Date
Patrick Steinhardt
8a4a343a2b blame_git: handle error returned by git_commit_parent 2016-03-11 14:20:15 +01:00
Patrick Steinhardt
b27ccad274 refdb_fs: fail if refcache returns NULL pointer
We usually check entries returned by `git_sortedcache_entry` for
NULL pointers. As we have a write lock in `packed_write`, though,
it really should not happen that the function returns NULL.

Assert that ref is not NULL to silence a Coverity warning.
2016-03-11 14:20:15 +01:00
Patrick Steinhardt
1a8c11f443 diff_tform: fix potential NULL pointer access
When the user passes in a diff which has no repository associated
we may call `git_config__get_int_force` with a NULL-pointer
configuration. Even though `git_config__get_int_force` is
designed to swallow errors, it is not intended to be called with
a NULL pointer configuration.

Fix the issue by only calling `git_config__get_int_force` only
when configuration could be retrieved from the repository.
2016-03-11 13:30:33 +01:00
Patrick Steinhardt
486302d6af submodule: avoid passing NULL pointers to strncmp
In C89 it is undefined behavior to pass `NULL` pointers to
`strncmp` and later on in C99 it has been explicitly stated that
functions with an argument declared as `size_t nmemb` specifying
the array length shall always have valid parameters, no matter if
`nmemb` is 0 or not (see ISO 9899 §7.21.1.2).

The function `str_equal_no_trailing_slash` always passes its
parameters to `strncmp` if their lengths match. This means if one
parameter is `NULL` and the other one either `NULL` or a string
with length 0 we will pass the pointers to `strncmp` and cause
undefined behavior.

Fix this by explicitly handling the case when both lengths are 0.
2016-03-11 12:14:02 +01:00
Patrick Steinhardt
3fe5768b06 pack-objects: fix memory leak on overflow 2016-03-11 12:14:02 +01:00
Patrick Steinhardt
80a834a5af index: assert required OID are non-NULL 2016-03-11 12:14:01 +01:00
Patrick Steinhardt
61d7328dc3 object: avoid call of memset with ouf of bounds pointer
When computing a short OID we do this by first copying the
leading parts into the new OID structure and then setting the
trailing part to zero. In the case of the desired length being
`GIT_OID_HEXSZ - 1` we will call `memset` with an out of bounds
pointer and a length of 0. While this seems to cause no problems
for common platforms the C89 standard does not explicitly state
that calling `memset` with an out of bounds pointer and
length of 0 is valid.

Fix the potential issue by using the newly introduced
`git_oid__cpy_prefix` function.
2016-03-11 12:14:01 +01:00
Patrick Steinhardt
e126bc95cd config_file: handle missing quotation marks in section header
When parsing a section header we expect something along the
format of '[section "subsection"]'. When a section is
mal-formated and is entirely missing its quotation marks we catch
this case by observing that `strchr(line, '"') - strrchr(line,
'"') = NULL - NULL = 0` and error out. Unfortunately, the error
message is misleading though, as we state that we are missing the
closing quotation mark while we in fact miss both quotation
marks.

Improve the error message by explicitly checking if the first
quotation mark could be found and, if not, stating that quotation
marks are completely missing.
2016-03-10 10:28:33 +01:00
Patrick Steinhardt
345758ad45 describe: handle error code returned by git_pqueue_insert 2016-03-10 10:28:32 +01:00
Edward Thomson
997c67da00 Merge pull request #3670 from libgit2/vmg/expand-fixes
Fixes for `gid_odb_expand_ids`
2016-03-09 18:12:34 +00:00
Vicent Marti
1bbcb2b279 odb: Try to lookup headers in all backends before passthrough 2016-03-09 18:17:37 +01:00
Vicent Marti
e78d2ac939 odb: Refactor git_odb_expand_ids 2016-03-09 16:43:43 +01:00
Vicent Marti
4416aa7749 odb: Implement new helper to read types without refreshing 2016-03-09 16:43:17 +01:00
Carlos Martín Nieto
d50fd57174 mwindow: free unused windows if we fail to mmap
The first time may be due to memory fragmentation or just bad luck on a
32-bit system. When we hit the mmap error for the first time, free up
the unused windows and try again.
2016-03-09 11:16:16 +01:00
Vicent Marti
9a78665005 odb: Handle corner cases in git_odb_expand_ids
The old implementation had two issues:

1. OIDs that were too short as to be ambiguous were not being handled
properly.

2. If the last OID to expand in the array was missing from the ODB, we
would leak a `GIT_ENOTFOUND` error code from the function.
2016-03-09 11:00:27 +01:00
Vicent Marti
c68044a879 Merge pull request #3656 from ethomson/exists_prefixes
Introduce `git_odb_expand_ids`
2016-03-08 21:17:38 +01:00
Edward Thomson
62484f52d1 git_odb_expand_ids: accept git_odb_expand_id array
Take (and write to) an array of a struct, `git_odb_expand_id`.
2016-03-08 14:57:20 -05:00
Edward Thomson
4b1f0f79ac git_odb_expand_ids: rename func, return the type 2016-03-08 11:44:21 -05:00
Chris Hescock
9028a8a22a Only buffer if necessary. 2016-03-08 10:43:37 -05:00
Edward Thomson
b7809b8469 Merge pull request #3555 from cbargren/ssh-git-protocols
Support for ssh+git and git+ssh protocols
2016-03-08 13:38:55 +00:00
Carlos Martín Nieto
47cb42da5a commit: split creating the commit and writing it out
Sometimes you want to create a commit but not write it out to the
objectdb immediately. For these cases, provide a new function to
retrieve the buffer instead of having to go through the db.
2016-03-08 13:11:49 +01:00
Edward Thomson
6c04269c8f git_odb_exists_many_prefixes: query odb for multiple short ids
Query the object database for multiple objects at a time, given their
object ID (which may be abbreviated) and optional type.
2016-03-07 16:10:25 -05:00
Edward Thomson
e10144ae57 odb: improved not found error messages
When looking up an abbreviated oid, show the actual (abbreviated) oid
the caller passed instead of a full (but ambiguously truncated) oid.
2016-03-07 10:20:01 -05:00
Carlos Martín Nieto
ea5bf6bbce treebuilder: don't try to verify submodules exist in the odb
Submodules don't exist in the objectdb and the code is making us try to
look for a blob with its commit id, which is obviously not going to
work.

Skip the test if the user wants to insert a submodule.
2016-03-04 12:38:28 +01:00
Carlos Martín Nieto
22f3d3aa6b ssh: initialize libssh2
We should have been doing this, but it initializes itself upon first
use, which works as long as nobody's doing concurrent network
operations. Initialize it on our init to make sure it's not getting
initialized concurrently.
2016-03-03 22:26:31 +01:00
Carlos Martín Nieto
66a530eb4e Merge pull request #3648 from libgit2/cmn/auth-retry
test: make sure we retry the auth callback on all platforms
2016-03-03 20:11:18 +01:00
Carlos Martín Nieto
778fb695ed Merge pull request #3646 from pks-t/pks/xdiff-fix-from-upstream
xdiff: fix memleak on error case
2016-03-03 12:14:02 +01:00
Carlos Martín Nieto
a4cba9d453 winhttp: retry authentication
If the caller has provided bad authentication, give them another
apportunity to get it right until they give up. This brings WinHTTP in
line with the other transports.
2016-03-03 11:18:03 +01:00
Edward Thomson
edaffe22a2 Merge pull request #3633 from ethomson/safe_creation
Stricter object dependency checking during creation
2016-03-01 17:16:27 +00:00
Patrick Steinhardt
a4ea7faaad xdiff: fix memleak on error case
Commit 3d1abc5afc fixes a memory leak in the xdiff code. In the
process of upstreaming the fix it was pointed out by Johannes
Schindelin that there is another memory leak present (see [1]).

Fix the second memory leak by applying the upstream fix to our
code base.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/287034
2016-03-01 08:56:23 +01:00
Edward Thomson
dbee683553 Merge pull request #3567 from sba1/few-p_getaddrinfo-fixes
Few p_getaddrinfo fixes
2016-02-28 20:13:24 -05:00
Edward Thomson
f2dddf52c0 turn on strict object validation by default 2016-02-28 18:59:43 -05:00
Edward Thomson
98c341496f refs: honor strict object creation 2016-02-28 18:54:39 -05:00
Edward Thomson
3ef01e7727 git_object__is_valid: use odb_read_header
This allows lighter weight validation in `git_object__is_valid` that
does not require reading the entire object.
2016-02-28 18:54:39 -05:00
Edward Thomson
6ddf533afc git_index_add: validate objects in index entries (optionally)
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the index entries given to `git_index_add`.
2016-02-28 18:54:39 -05:00
Edward Thomson
2bbc7d3e56 treebuilder: validate tree entries (optionally)
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to treebuilder insertion.
2016-02-28 12:38:40 -05:00
Edward Thomson
ef63bab306 git_commit: validate tree and parent ids
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to commit creation functions.
2016-02-28 12:38:39 -05:00
Edward Thomson
7565dc6572 git_object__is_valid: simple object validity test 2016-02-28 12:38:39 -05:00
Edward Thomson
22a19f5b57 git_libgit2_opts: introduce GIT_OPT_ENABLE_STRICT_OBJECT_CREATION 2016-02-28 12:38:39 -05:00
Edward Thomson
6cc4bac894 Merge pull request #3577 from rossdylan/rossdylan/pooldebug
Add a new build flag to disable the pool allocator
2016-02-28 11:31:10 -05:00
Ross Delinger
93e1664228 Fixed typo in one of the ifndef's in pool.h used to enable/disable debug mode 2016-02-26 12:51:13 -05:00
Carlos Martín Nieto
9f4e7c8490 Merge pull request #3638 from ethomson/nsec
USE_NSECS fixes
2016-02-25 18:42:09 +01:00
Edward Thomson
0d9a7498c5 Merge pull request #3628 from pks-t/pks/coverity-fixes
Coverity fixes
2016-02-25 12:09:49 -05:00
Edward Thomson
fd129f28f1 Merge pull request #3630 from libgit2/cmn/idx-extra-check
Extra checks for packfile indices
2016-02-25 11:59:00 -05:00
Edward Thomson
3d6a42d1e1 nsec: support NDK's crazy nanoseconds
Android NDK does not have a `struct timespec` in its `struct stat`
for nanosecond support, instead it has a single nanosecond member inside
the struct stat itself.  We will use that and use a macro to expand to
the `st_mtim` / `st_mtimespec` definition on other systems (much like
the existing `st_mtime` backcompat definition).
2016-02-25 11:40:48 -05:00
Carlos Martín Nieto
6d97beb91f pack: don't allow a negative offset 2016-02-25 15:46:59 +01:00
Carlos Martín Nieto
ea9e00cb5c pack: make sure we don't go out of bounds for extended entries
A corrupt index might have data that tells us to go look past the end of
the file for data. Catch these cases and return an appropriate error
message.
2016-02-25 15:43:17 +01:00
Carlos Martín Nieto
68ad3156a0 openssl: we already had the function, just needed the header 2016-02-24 17:17:57 +01:00
Carlos Martín Nieto
f3d1be7d62 openssl: export the locking function when building without OpenSSL
This got lost duing the move and it lets the users call this function
just in case.
2016-02-24 16:38:22 +01:00
Edward Thomson
04c3b35f9c map: use giterr_set internally
Use the `giterr_set` function, which actually supports `GITERR_OS`.
The `giterr_set_str` function is exposed for external users and will
not append the operating system's error message.
2016-02-23 13:08:50 -05:00
Patrick Steinhardt
32f0798413 diff_tform: fix potential NULL pointer access
The `normalize_find_opts` function in theory allows for the
incoming diff to have no repository. When the caller does not
pass in diff find options or if the GIT_DIFF_FIND_BY_CONFIG value
is set, though, we try to derive the configuration from the
diff's repository configuration without first verifying that the
repository is actually set to a non-NULL value.

Fix this issue by explicitly checking if the repository is set
and if it is not, fall back to a default value of
GIT_DIFF_FIND_RENAMES.
2016-02-23 12:07:37 +01:00
Patrick Steinhardt
3d1abc5afc xmerge: fix memory leak on error path 2016-02-23 12:07:37 +01:00
Patrick Steinhardt
05bf67b901 openssl_stream: fix NULL pointer dereference 2016-02-23 12:07:37 +01:00
Patrick Steinhardt
2baf854e97 openssl_stream: fix memory leak when creating new stream 2016-02-23 12:07:36 +01:00
Patrick Steinhardt
2afb6fa46d rebase: plug memory leak in rebase_alloc
Convert `rebase_alloc` to use our usual error propagation
patterns, that is accept an out-parameter and return an error
code that is to be checked by the caller. This allows us to use
the GITERR_CHECK_ALLOC macro, which helps static analysis.
2016-02-23 12:07:36 +01:00
Patrick Steinhardt
d0cb11e794 remote: set error code in create_internal
Set the error code when an error occurs in any of the called
functions. This ensures we pass the error up to callers and
actually free the remote when an error occurs.
2016-02-23 12:07:36 +01:00
Patrick Steinhardt
0f1e2d2066 index: fix contradicting comparison
The overflow check in `read_reuc` tries to verify if the
`git__strtol32` parses an integer bigger than UINT_MAX. The `tmp`
variable is casted to an unsigned int for this and then checked
for being greater than UINT_MAX, which obviously can never be
true.

Fix this by instead fixing the `mode` field's size in `struct
git_index_reuc_entry` to `uint32_t`. We can now parse the int
with `git__strtol64`, which can never return a value bigger than
`UINT32_MAX`, and additionally checking if the returned value is
smaller than zero.

We do not need to handle overflows explicitly here, as
`git__strtol64` returns an error when the returned value would
overflow.
2016-02-23 12:07:14 +01:00
Patrick Steinhardt
7808c93797 index: plug memory leak in read_conflict_names 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
003c5e46a8 transports: smart_pkt: fix memory leaks on error paths 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
793e085536 refdb_fs: remove unnecessary check for NULL
The fail-label of `reflog_parse` explicitly checks the entry
poitner for NULL before freeing it. When we jump to the label the
variable has to be set to a non-NULL and valid pointer though: if
the allocation fails we immediately return with an error code and
if the loop was not entered we return with a success code,
withouth executing the label's code.

Remove the useless NULL-check to silence Coverity.
2016-02-23 11:50:23 +01:00
Patrick Steinhardt
be8479c987 diff_print: assert patch is non-NULL
When invoking `diff_print_info_init_frompatch` it is obvious that
the patch should be non-NULL. We explicitly check if the variable
is set and continue afterwards, happily dereferencing the
potential NULL-pointer.

Fix this by instead asserting that patch is set. This also
silences Coverity.
2016-02-23 11:50:23 +01:00
Patrick Steinhardt
bac52ab0f2 pack-objects: return early when computing write order fails
The function `compute_write_order` may return a `NULL`-pointer
when an error occurs. In such cases we jump to the `done`-label
where we try to clean up allocated memory. Unfortunately we try
to deallocate the `write_order` array, though, which may be NULL
here.

Fix this error by returning early instead of jumping to the
`done` label. There is no data to be cleaned up anyway.
2016-02-23 11:50:23 +01:00
Patrick Steinhardt
d1c9a48df6 pack-objects: check realloc in try_delta with GITERR_CHECK_ALLOC 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
2129d6df93 crlf: do not ignore GIT_PASSTHROUGH error
When no payload is set for `crlf_apply` we try to compute the
crlf attributes ourselves with `crlf_check`. When the function
determines that the current file does not require any treatment
we return the GIT_PASSTHROUGH error code without actually
allocating the out-pointer, which indicates the file should not
be passed through the filter.

The `crlf_apply` function explicitly checks for the
GIT_PASSTHROUGH return code and ignores it. This means we will
try to apply the crlf-filter to the current file, leading us to
dereference the unallocated payload-pointer.

Fix this obviously incorrect behavior by not treating
GIT_PASSTHROUGH in any special way. This is the correct thing to
do anyway, as the code indicates that the file should not be
passed through the filter.
2016-02-23 11:50:23 +01:00
Patrick Steinhardt
b9f28b8d52 refspec: check buffer with GITERR_CHECK_ALLOC_BUF 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
c5bd70d138 revwalk: use GITERR_CHECK_ALLOC_BUF 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
6e2a37556d smart_pkt: check buffer with GITERR_CHECK_ALLOC_BUF 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
42c05ed56b path: use GITERR_CHECK_ALLOC_BUF to verify passed in buffer 2016-02-23 11:50:23 +01:00
Patrick Steinhardt
859ed5ddc7 common: introduce GITERR_CHECK_ALLOC_BUF
We commonly have to check if a git_buf has been allocated
correctly or if we ran out of memory. Introduce a new macro
similar to `GITERR_CHECK_ALLOC` which checks if we ran OOM and if
so returns an error. Provide a `#nodef` for Coverity to mark the
error case as an abort path.
2016-02-23 11:50:23 +01:00
Edward Thomson
7bab2e8fbf git_libgit2_opts: validate key 2016-02-22 23:07:30 -05:00
Carlos Martín Nieto
c8fe6c0975 openssl: re-export the last-resort locking function
We need to include the header where we define the function. Otherwise it
won't be available on the DLL.
2016-02-19 16:23:14 +01:00
Ross Delinger
f1260e03d9 Remove unnecessary ifdef in pool.h 2016-02-19 09:13:40 -05:00
Carlos Martín Nieto
deecaa2ece openssl: free the context even if we don't connect 2016-02-19 13:34:52 +01:00
Carlos Martín Nieto
bf127eec4a global: remove an unused variable 2016-02-19 13:24:41 +01:00
Carlos Martín Nieto
78e16c3442 Merge pull request #3597 from ethomson/filter_registration
Filter registration
2016-02-19 13:06:51 +01:00
Patrick Steinhardt
8a62bf1180 netops: fix memory leak when an error occurs 2016-02-18 20:50:33 +01:00
Patrick Steinhardt
b0f7512f40 transports: smart_pkt: fix memory leaks 2016-02-18 20:50:33 +01:00
Patrick Steinhardt
704554cdf0 transports: smart: fix memory leak on OOM path 2016-02-18 20:50:33 +01:00
Patrick Steinhardt
038d7af085 signature: use GITERR_CHECK_ALLOC to check for OOM situation
When checking for out of memory situations we usually use the
GITERR_CHECK_ALLOC macro. Besides conforming to our current code
base it adds the benefit of silencing errors in Coverity due to
Coverity handling the macro's error path as abort.
2016-02-18 20:50:33 +01:00
Carlos Martín Nieto
c1b75f05ad Merge pull request #3604 from ethomson/nsec_xplat
Handle `USE_NSECS`
2016-02-18 15:11:31 +01:00
Carlos Martín Nieto
b85d0afd6e Merge pull request #3606 from ethomson/drop_xp
win32: drop xp support in WideCharToMultiByte
2016-02-18 15:11:02 +01:00
Carlos Martín Nieto
5663d4f691 Merge pull request #3613 from ethomson/fixups
Remove most of the silly warnings
2016-02-18 12:31:56 +01:00
Carlos Martín Nieto
594a5d12d4 Merge pull request #3619 from ethomson/win32_forbidden
win32: allow us to read indexes with forbidden paths on win32
2016-02-18 12:28:06 +01:00
Edward Thomson
318b825e76 index: allow read of index w/ illegal entries
Allow `git_index_read` to handle reading existing indexes with
illegal entries.  Allow the low-level `git_index_add` to add
properly formed `git_index_entry`s even if they contain paths
that would be illegal for the current filesystem (eg, `AUX`).
Continue to disallow `git_index_add_bypath` from adding entries
that are illegal universally illegal (eg, `.git`, `foo/../bar`).
2016-02-17 13:10:33 +00:00
Edward Thomson
4fea9cffbd iterator: assert tree_iterator has a frame
Although a `tree_iterator` that failed to be properly created
does not have a frame, all other `tree_iterator`s should.  Do not
call `pop` in the failure case, but assert that in all other
cases there is a frame.
2016-02-17 13:10:33 +00:00
Colin Xu
a218b2f625 Validate pointer before access the member.
When Git repository at network locations, sometimes git_iterator_for_tree
fails at iterator__update_ignore_case so it goes to git_iterator_free.
Null pointer will crash the process if not check.

Signed-off-by: Colin Xu <colin.xu@gmail.com>
2016-02-17 13:10:33 +00:00
Carlos Martín Nieto
eadd0f05f6 commit: expose the different kinds of errors
We should be checking whether the object we're looking up is a commit,
and we should let the caller know whether the not-found return code
comes from a bad object type or just a missing signature.
2016-02-16 14:06:48 +01:00
Edward Thomson
9ce0399c4d winhttp: use an unsigned iterator 2016-02-16 11:50:49 +00:00
Edward Thomson
3b2fa0fb36 submodule: explicitly cast to the teensy time value 2016-02-16 11:50:48 +00:00
Edward Thomson
b2ca8d9c29 index: explicitly cast the teeny index entry members 2016-02-16 11:50:47 +00:00
Edward Thomson
997e030154 index: don't use seek return as an error code 2016-02-16 11:50:47 +00:00
Edward Thomson
9a634cba85 index: explicitly cast new hash size to an int 2016-02-16 11:50:46 +00:00
Edward Thomson
c4d23928c3 fstat: use our custom stat 2016-02-16 11:50:45 +00:00
Edward Thomson
aadad40592 tree: zap warnings around size_t vs uint16_t 2016-02-16 11:50:44 +00:00
Edward Thomson
f28bae0c38 rebase: persist a single in-memory index
When performing an in-memory rebase, keep a single index for the
duration, so that callers have the expected index lifecycle and
do not hold on to an index that is free'd out from under them.
2016-02-15 19:27:06 +00:00
Edward Thomson
35439f5997 win32: introduce p_timeval that isn't stupid
Windows defines `timeval` with `long`, which we cannot
sanely cope with.  Instead, use a custom timeval struct.
2016-02-12 10:34:15 -08:00
Carlos Martín Nieto
5a296ad07e Merge pull request #3610 from ethomson/rebase_bare
rebase: introduce bare rebasing
2016-02-12 00:55:20 +01:00
Arthur Schreiber
3679ebaef5 Horrible fix for #3173. 2016-02-11 23:41:34 +01:00
Carlos Martín Nieto
460ae11f0a commit: don't forget the last header field
When we moved the logic to handle the first one, wrong loop logic was
kept in place which meant we still finished early. But we now notice it
because we're not reading past the last LF we find.

This was not noticed before as the last field in the tested commit was
multi-line which does not trigger the early break.
2016-02-11 22:19:20 +01:00
Edward Thomson
a202e0d45b rebase: allow custom merge_options
Allow callers of rebase to specify custom merge options.  This may
allow custom conflict resolution, or failing fast when conflicts
are detected.
2016-02-11 10:49:25 -08:00
Edward Thomson
ee6673070a rebase: introduce inmemory rebasing
Introduce the ability to rebase in-memory or in a bare repository.

When `rebase_options.inmemory` is specified, the resultant `git_rebase`
session will not be persisted to disk.  Callers may still analyze
the rebase operations, resolve any conflicts against the in-memory
index and create the commits.  Neither `HEAD` nor the working
directory will be updated during this process.
2016-02-11 10:48:48 -08:00
Edward Thomson
494e61b8a3 win32: drop xp support in WideCharToMultiByte 2016-02-09 21:45:24 -08:00
Edward Thomson
9447b9e55a xplat: use st_mtimespec everywhere on mac 2016-02-09 10:40:33 -08:00
Vicent Marti
488e2b8505 Merge pull request #3599 from libgit2/gpgsign
Introduce git_commit_extract_signature
2016-02-09 16:26:58 +01:00
Carlos Martín Nieto
534cc5a3cb Merge pull request #3603 from pks-t/pks/coverity-fixes
Coverity fixes
2016-02-09 16:10:43 +01:00
Carlos Martín Nieto
a65afb757e Introduce git_commit_extract_signature
This returns the GPG signature for a commit and its contents without the
signature block, allowing for the verification of the commit's
signature.
2016-02-09 15:58:16 +01:00
Carlos Martín Nieto
ab87cb1818 Merge pull request #3602 from libgit2/cmn/header-field-2
commit: also match the first header field when searching
2016-02-09 14:53:10 +01:00
Patrick Steinhardt
24b8ed2b3a attr_file: fix resource leak 2016-02-09 11:11:38 +01:00
Patrick Steinhardt
e262545753 checkout: fix resource leak 2016-02-09 11:09:41 +01:00
Patrick Steinhardt
39c9dd24d3 pack-objects: fix memory leak in packbuilder_config 2016-02-09 10:53:30 +01:00
Patrick Steinhardt
0b2437bb68 pack-objects: fix memory leak in compute_write_order 2016-02-09 10:43:28 +01:00
Patrick Steinhardt
a53d2e3985 pack: do not free passed in poiter on error
The function `git_packfile_stream_open` tries to free the passed
in stream when an error occurs. The only call site is
`git_indexer_append`, though, which passes in the address of a
stream struct which has not been allocated on the heap.

Fix the issue by simply removing the call to free. In case of an
error we did not allocate any memory yet and otherwise it should
be the caller's responsibility to manage it's object's lifetime.
2016-02-09 09:58:56 +01:00
Carlos Martín Nieto
f55eca167c commit: also match the first header field when searching
We were searching only past the first header field, which meant we were
unable to find e.g. `tree` which is the first field.

While here, make sure to set an error message in case we cannot find the
field.
2016-02-09 07:17:26 +01:00
Edward Thomson
2ed855a9e8 filter: avoid races during filter registration
Previously we would set the global filter registry structure before
adding filters to the structure, without a lock, which is quite racy.
Now, register default filters during global registration and use an
rwlock to read and write the filter registry (as appopriate).
2016-02-08 16:31:42 -08:00
Edward Thomson
6e0fc1a631 mingw: use gcc-like memory barrier
Use the gcc-like memory barrier (__sync_synchronize) on mingw.
2016-02-08 16:30:41 -08:00
Edward Thomson
8a6d667763 global: make openssl registration like the rest 2016-02-08 16:30:39 -08:00
Edward Thomson
bad2702c43 global: refactor setup and cleanup
Move the common initialization and cleanup methods to reduce
unnecessary duplication.
2016-02-08 15:39:26 -08:00
Patrick Steinhardt
a001846b25 curl_stream: fix unused cert infos
When copying contents of the cURL certiinfo we duplicate the
data but forget to actually put it into the vector.
2016-02-08 17:05:57 +01:00
Patrick Steinhardt
fac42ff942 merge: fix memory leak 2016-02-08 16:58:08 +01:00
Carlos Martín Nieto
240b6fed00 Merge pull request #3578 from bubaflub/fix_small_memory_leak
Free allocated pointer to curl stream on error
2016-02-05 15:19:24 -08:00
Marius Ungureanu
0c09753cf5 Fix the build when defining USE_NSEC 2016-01-25 14:06:15 +02:00
Edward Thomson
5c7f2f0188 winhttp: name mangle class / iid on mingw
Standard Windows type systems define CLSID_InternetSecurityManager
and IID_IInternetSecurityManager, but MinGW lacks these definitions.
As a result, we must hardcode these definitions ourselves.  However,
we should not use a public struct with those names, lest another
library do the same thing and consumers cannot link to both.
2016-01-19 11:13:23 -06:00
Bob Kuo
8bd1c19e76 Free allocated pointer to curl stream on error 2016-01-16 19:39:24 -06:00
P.S.V.R
d4e4f27204 Remove duplicated calls to git_mwindow_close 2016-01-13 11:07:14 +08:00
P.S.V.R
b644e223aa Make packfile_unpack_compressed a private API 2016-01-13 11:02:38 +08:00
Ross Delinger
ed0571f895 Add a new build flag to disable the pool allocator and pass all git_pool_malloc calls straight to git__malloc 2016-01-12 16:08:38 -05:00
Chris Hescock
a7d9d93dad Buffer sideband packet data
The inner packet may be split across multiple sideband packets.
2016-01-12 10:08:58 -05:00
Yong Li
b3eb2cde2b Avoid subtraction overflow in git_indexer_commit 2016-01-04 10:47:00 -05:00
Sebastian Bauer
9f9df4b6e0 Copy into the correct destination. 2015-12-31 14:52:32 +01:00
Sebastian Bauer
ea5942b4cf Bail out early when no memory is available. 2015-12-31 14:52:24 +01:00
Carlos Martín Nieto
700f0aff24 Merge pull request #3562 from mgorny/ssh-read-stderr-fail
ssh_stream_read(): fix possible *bytes_read < 0 branch
2015-12-29 13:38:01 +00:00
Chris Bargren
813d73f64d Tabs 2015-12-28 11:45:12 -07:00
Chris Bargren
4df17045c1 Removing #define for SSH_PREFIX_COUNT and using ARRAY_SIZE instead
Also moving var declarations to top of blocks to support bad old compilers
2015-12-28 11:45:00 -07:00
Carlos Martín Nieto
a3776489e6 Merge pull request #3558 from libgit2/cmn/index-nolock
index: get rid of the locking
2015-12-28 15:12:37 +00:00
Carlos Martín Nieto
9d81509ab1 index: get rid of the locking
We don't support using an index object from multiple threads at the same
time, so the locking doesn't have any effect when following the
rules. If not following the rules, things are going to break down
anyway.
2015-12-28 13:55:44 +00:00
Edward Thomson
62602547db git_repository_init: include dotfiles when copying templates
Include dotfiles when copying template directory, which will handle
both a template directory itself that begins with a dotfile, and
any dotfiles inside the directory.
2015-12-26 22:41:00 -06:00
Edward Thomson
869320a85d Merge pull request #3546 from Cruel/master
Fix a couple function signatures
2015-12-26 16:55:29 -06:00
Michał Górny
02fdc2db22 ssh_stream_read(): fix possible *bytes_read < 0 branch
Fix the possibility of returning successfully from ssh_stream_read()
with *bytes_read < 0. This would occur if stdout channel read resulted
in 0, and stderr channel read failed afterwards.
2015-12-26 17:17:05 +01:00
Chris Bargren
ed21fd745c Handle git+ssh:// and ssh+git:// protocols support 2015-12-22 10:38:31 -07:00
Dmitriy Olshevskiy
91f0d186b4 typos in comments 2015-12-21 22:18:07 +03:00
Vicent Marti
ef8b7febc5 index: Also size-hint the hash table
Note that we're not checking whether the resize succeeds; in OOM cases,
we let it run with a "small" vector and hash table and see if by chance
we can grow it dynamically as we insert the new entries. Nothing to
lose really.
2015-12-16 19:36:50 +01:00
Vicent Marti
d7d46cfbfd index: Preallocate the entries vector with size hint 2015-12-16 17:04:08 +01:00
Vicent Marti
0cc20a8c48 index: Adjust namemask & mode when filling 2015-12-16 17:04:08 +01:00
Vicent Marti
879ebab314 merge: Use git_index__fill to populate the index
Instead of calling `git_index_add` in a loop, use the new
`git_index_fill` internal API to fill the index with the initial staged
entries.

The new `fill` helper assumes that all the entries will be unique and
valid, so it can append them at the end of the entries vector and only
sort it once at the end. It performs no validation checks.

This prevents the quadratic behavior caused by having to sort the
entries list once after every insertion.
2015-12-16 12:30:52 +01:00
Thomas Edvalson
95746a57c7 Fix a couple function signatures 2015-12-14 19:21:09 -05:00
Edward Thomson
7f2c1469f8 Merge pull request #3528 from chescock/Passthrough-from-credential-callback
Treat GIT_PASSTHROUGH as though git_cred_acquire_cb isn't set.
2015-12-14 13:54:02 -06:00
Edward Thomson
30c8e26074 Merge pull request #3521 from pks-t/blame-line-overflow
Line count overflow in git_blame_hunk and git_blame__entry
2015-12-14 13:53:26 -06:00
Carlos Martín Nieto
6aa06b65cf Merge pull request #3522 from pks-t/email-format-commit-message
diff: include commit message when formatting patch
2015-12-10 12:14:09 +01:00
Carlos Martín Nieto
dc49eb585f Merge pull request #3538 from pks-t/pks/index-memory-leak
index: always queue `remove_entry` for removal
2015-12-10 11:57:44 +01:00
Carlos Martín Nieto
465c3b38d5 reset: perform the checkout before moving HEAD or the index
This keeps the state of the workdir the same as one from HEAD, removing
a source of possible confusion when calculating the work that is to be
done.
2015-12-09 19:16:11 +01:00