Commit Graph

9535 Commits

Author SHA1 Message Date
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
Edward Thomson
a4c55069e3 nsec: update staging test for GIT_USE_NSECS
The index::nsec::staging_maintains_other_nanos test was created to
ensure that when we stage an entry when GIT_USE_NSECS is *unset* that
we truncate the index entry and do not persist the (old, invalid)
nanosec values.  Ensure that when GIT_USE_NSECS is *set* that we do
not do that, and actually write the correct nanosecond values.
2016-02-25 11:40:40 -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
Edward Thomson
9dfe11403a Merge pull request #3637 from libgit2/cmn/conventions
CONVENTIONS: update to include general public API principles
2016-02-25 09:08:23 -05:00
Carlos Martín Nieto
1f8cb02f51 CONVENTIONS: update to include general public API principles 2016-02-25 14:51:00 +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
Carlos Martín Nieto
43955927e4 Merge pull request #3631 from ethomson/giterr_fixups
Minor `giterr` fixups
2016-02-23 22:27:36 +01:00
Edward Thomson
cd59e0c0c7 giterr_set_str: remove GITERR_OS documentation
The `giterr_set_str` does not actually honor `GITERR_OS`.  Remove
the documentation that claims that we do.
2016-02-23 13:08:58 -05: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
Patrick Steinhardt
f2a554b45e coverity: hint git_vector_foreach does not deref NULL contents
Coverity does not comprehend the connection between a vector's
size and the contents pointer, that is that the vector's pointer
is non-NULL when its size is positive. As the vector code should
be reasonably well tested and users are expected to not manually
modify a vector's contents it seems save to assume that the
macros will never dereference a NULL pointer.

Fix Coverity warnings by overriding the foreach macros with
macros that explicitly aborting when (v)->contents is NULL.
2016-02-23 11:50:23 +01:00
Vicent Marti
fb96b28cd9 Merge pull request #3629 from ethomson/set_user_agent_doc
git_libgit2_opts: minor documentation & usage fixes
2016-02-23 08:16:12 +01:00
Edward Thomson
7bab2e8fbf git_libgit2_opts: validate key 2016-02-22 23:07:30 -05:00
Edward Thomson
5bc93eaea0 git_libgit2_opts: document GIT_OPT_SET_USER_AGENT 2016-02-22 22:26:01 -05:00
Edward Thomson
305c4f95ce Merge pull request #3627 from libgit2/cmn/typo
Fix a few checkout -> rebase typos
2016-02-22 10:16:49 -05:00
Carlos Martín Nieto
88ab3be6f5 Fix a few checkout -> rebase typos 2016-02-22 15:41:01 +01: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
f596946f09 CHANGELOG: add a few missing changes 2016-02-19 13:52:04 +01: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
Carlos Martín Nieto
b643501dba Merge pull request #3614 from pks-t/pks/coverity-fixes
Coverity fixes
2016-02-19 10:21:37 +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