Commit Graph

10689 Commits

Author SHA1 Message Date
Carlos Martín Nieto
d2451fedfa Merge pull request #3984 from pks-t/pks/pack-find-offset-race
pack: fix race in pack_entry_find_offset
2016-11-02 13:05:35 +01:00
Carlos Martín Nieto
2f3adf9513 openssl: use ASN1_STRING_get0_data when compiling against 1.1
For older versions we can fall back on the deprecated ASN1_STRING_data.
2016-11-02 13:02:13 +01:00
Carlos Martín Nieto
f15eedb3a3 openssl: recreate the OpenSSL 1.1 BIO interface for older versions
We want to program against the interface, so recreate it when we compile
against pre-1.1 versions.
2016-11-02 13:00:30 +01:00
Patrick Steinhardt
0cf15e39f3 pack: fix race in pack_entry_find_offset
In `pack_entry_find_offset`, we try to find the offset of a
certain object in the pack file. To do so, we first assert if the
packfile has already been opened and open it if not. Opening the
packfile is guarded with a mutex, so concurrent access to this is
in fact safe.

What is not thread-safe though is our calculation of offsets
inside the packfile. Assume two threads calling
`pack_entry_find_offset` at the same time. We first calculate the
offset and index location and only then determine if the pack has
already been opened. If so, we re-calculate the offset and index
address.

Now the case for two threads: thread 1 first calculates the
addresses and is subsequently suspended. The second thread will
now call `pack_index_open` and initialize the pack file,
calculating its addresses correctly. When the first thread is
resumed now, he'll see that the pack file has already been
initialized and will happily proceed with the addresses it has
already calculated before the check. As the pack file was not
initialized before, these addresses are bogus.

Fix the issue by only calculating the addresses after having
checked if the pack file is open.
2016-11-02 12:23:12 +01:00
Patrick Steinhardt
62494bf234 transports: smart: abort receiving packets on end of stream
When trying to receive packets from the remote, we loop until
either an error distinct to `GIT_EBUFS` occurs or until we
successfully parsed the packet. This does not honor the case
where we are looping over an already closed socket which has no
more data, leaving us in an infinite loop if we got a bogus
packet size or if the remote hang up.

Fix the issue by returning `GIT_EEOF` when we cannot read data
from the socket anymore.
2016-11-02 09:42:56 +01:00
Patrick Steinhardt
61530c497d transports: smart: abort ref announcement on early end of stream
When reading a server's reference announcements via the smart
protocol, we expect the server to send multiple flushes before
the protocol is finished. If we fail to receive new data from the
socket, we will only return an end of stream error if we have not
seen any flush yet.

This logic is flawed in that we may run into an infinite loop
when receiving a server's reference announcement with a bogus
flush packet. E.g. assume the last flushing package is changed to
not be '0000' but instead any other value. In this case, we will
still await one more flush package and ignore the fact that we
are not receiving any data from the socket, causing an infinite
loop.

Fix the issue by always returning `GIT_EEOF` if the socket
indicates an end of stream.
2016-11-02 09:41:39 +01:00
Patrick Steinhardt
19001ca7ba Merge pull request #3976 from pks-t/pks/pqueue-null-deref
pqueue: resolve possible NULL pointer dereference
2016-11-02 09:23:53 +01:00
Patrick Steinhardt
1c33ecc445 tests: core: test deinitialization and concurrent initialization
Exercise the logic surrounding deinitialization of the libgit2
library as well as repeated concurrent de- and reinitialization.
This tries to catch races and makes sure that it is possible to
reinitialize libgit2 multiple times.

After deinitializing libgit2, we have to make sure to setup
options required for testing. Currently, this only includes
setting up the configuration search path again. Before, this has
been set up once in `tests/main.c`.
2016-11-02 08:53:52 +01:00
Patrick Steinhardt
038f0e1b4c global: reset global state on shutdown without threading
When threading is not enabled for libgit2, we keep global state
in a simple static variable. When libgit2 is shut down, we clean
up the global state by freeing the global state's dynamically
allocated memory. When libgit2 is built with threading, we
additionally free the thread-local storage and thus completely
remove the global state. In a non-threaded build, though, we
simply leave the global state as-is, which may result in an error
upon reinitializing libgit2.

Fix the issue by zeroing out the variable on a shutdown, thus
returning it to its initial state.
2016-11-02 08:53:52 +01:00
Etienne Samson
8d400c096a transaction: fix documentation 2016-11-01 17:49:07 +01:00
Etienne Samson
788fcdb8e3 remote: fix documentation and indent 2016-11-01 17:46:57 +01:00
Etienne Samson
2adac91008 remote: unused function typedef 2016-11-01 17:46:37 +01:00
Etienne Samson
8d2784d570 describe: fix documentation 2016-11-01 17:46:20 +01:00
Patrick Steinhardt
6502398f96 proxy: fix typo in documentation 2016-11-01 16:55:16 +01:00
Patrick Steinhardt
59c6c2860a global: synchronize initialization and shutdown with pthreads
When trying to initialize and tear down global data structures
from different threads at once with `git_libgit2_init` and
`git_libgit2_shutdown`, we race around initializing data. While
we use `pthread_once` to assert that we only initilize data a
single time, we actually reset the `pthread_once_t` on the last
call to `git_libgit2_shutdown`. As resetting this variable is not
synchronized with other threads trying to access it, this is
actually racy when one thread tries to do a complete shutdown of
libgit2 while another thread tries to initialize it.

Fix the issue by creating a mutex which synchronizes `init_once`
and the library shutdown.
2016-11-01 14:30:47 +01:00
Carlos Martín Nieto
41ad9ebfad Merge pull request #3975 from pks-t/pks/ci-improvements
CI Improvements
2016-11-01 09:59:17 +01:00
Edward Thomson
a051ee31f2 Merge pull request #3978 from pks-t/pks/doc-improvements
Small documentation improvements
2016-10-31 16:02:43 +00:00
Patrick Steinhardt
0334bf4b24 travis: do not allow valgrind failures
Our valgrind jobs haven't been failing for several builds by now.
This indicates that our tests are sufficiently stable when
running under valgrind. As such, any failures reported by
valgrind become interesting to us and shouldn't be ignored when
causing a build to fail.

Remove the valgrind job from the list of allowed failures.
2016-10-31 16:01:10 +01:00
Patrick Steinhardt
18c18e3df8 coverity: check for Coverity token only if necessary
When running a Coverity build, we have to provide an
authentication token in order to proof that we are actually
allowed to run analysis in the name of a certain project. As this
token should be secret, it is only set on the main repository, so
when we were requested to run the Coverity script on another
repository we do error out. But in fact we do also error out if
the Coverity analysis should _not_ be run if there is no
authentication token provided.

Fix the issue by only checking for the authentication token after
determining if analysis is indeed requested.
2016-10-31 16:01:10 +01:00
Patrick Steinhardt
dc98cb28db openssl_stream: fix typo 2016-10-31 13:50:23 +01:00
Patrick Steinhardt
59665db3b3 PROJECTS: consistently quote directories 2016-10-31 13:50:13 +01:00
Patrick Steinhardt
ea9ea6ac4a Documentation: fix small typos 2016-10-31 13:49:52 +01:00
Patrick Steinhardt
95fa38802f pqueue: resolve possible NULL pointer dereference
The `git_pqueue` struct allows being fixed in its total number of
entries. In this case, we simply throw away items that are
inserted into the priority queue by examining wether the new item
to be inserted has a higher priority than the previous smallest
one.

This feature somewhat contradicts our pqueue implementation in
that it is allowed to not have a comparison function. In fact, we
also fail to check if the comparison function is actually set in
the case where we add a new item into a fully filled fixed-size
pqueue.

As we cannot determine which item is the smallest item in absence
of a comparison function, we fix the `NULL` pointer dereference
by simply dropping all new items which are about to be inserted
into a full fixed-size pqueue.
2016-10-28 16:19:24 +02:00
Patrick Steinhardt
561276eed6 coverity: only analyze the master branch of the main repository
We used to only execute Coverity analysis on the 'development'
branch before commit 998f001 (Refine build limitation,
2014-01-15), which refined Coverity build limitations. While we
do not really use the 'development' branch anymore, it does
still make sense to only analyze a single branch, as otherwise
Coverity might get confused.

Re-establish the restriction such that we only analyze libgit2's
'master' branch. Also fix the message announcing why we do not
actually analyze a certain build.
2016-10-28 14:56:10 +02:00
Patrick Steinhardt
6c4d2d3ea2 coverity: fix download URL 2016-10-28 14:45:55 +02:00
Patrick Steinhardt
e3298a3308 Merge pull request #3973 from pks-t/pks/memleak-fixes
Trivial memory leak fixes in test suite
2016-10-28 12:30:39 +02:00
Patrick Steinhardt
30a876cda6 tests: fetchhead: fix memory leak 2016-10-27 11:29:15 +02:00
Patrick Steinhardt
61ad9bcd38 tests: vector: fix memory leak 2016-10-27 11:26:52 +02:00
Russell Sim
bba110f034 Update changelog 2016-10-27 19:19:16 +11:00
Russell Sim
27a99ed552 Updated version
* Added patch for CVEs
* Bumped standards version
* Set debian hardening complie flags
* patched with fixes for CVEs
* Fix compile in GMT-14
2016-10-27 19:19:04 +11:00
Russell Sim
7c7a1dbfab Imported Upstream 0.24.2
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJYEbeBAAoJECKxCSrd3EfdhE0QAK0vY+jfoj7jj9IUShIkEvH/
 DcG/DXAkZAHDJvzugm31QWZtCES1s8cN4vKjdNiTEGOvzOlnlxR+GKwxmoEmYpxO
 R3KzvHTjLAXEQBMMvYikT9QT8/JV/WUQSdCfc82ZyPltq/lKcx0vXyLzpQ+MbZFu
 fAdQeZrvKBd0oEQqjw87+xAn95t7/XGzOT/j78AkSm4K6O531d3MXn96XRf8aWQ7
 vB8kc1JclsUn+EyYvIazhwrieoHbhOhJoAUoPb4OAyznoSZzwmnUwCuWws2OhstI
 QHwhz9HYtnDmBi0i19rHCmHG7M8hF/X3SIaaP94meAI3sGukNJvdqcxOITSLD0Hj
 fh6J/ddkorSjeuzQPTvJ/vTfo0mZTBiqvgUIR/Lk4BV4/aaWyylrU3Fv2DK1LAXH
 XLYVgJmQMCejIu24N/nOgTnYaipjpLDegTrnXtbcl3l/Y+ZG3lwDrgYUmwokMdPW
 8DsSsBfUw03td/6OSuDAjQuRrkam470bVPY1NlNA1iJq40N3AeQmNvRYvobCLrWn
 NdDGZGIworE/N+frcHIgolS0b6CYa3cOVsyk0R9CrPFJeAcTFrBShexcX9XnxKjH
 fP2LWQO4pkGmTtmbom31UWRe59lDM9PX/PAYL86OwL53al4lWVpxgu+pHwprU4E6
 P69DPEqJLjPLVhjHbkhp
 =pKRh
 -----END PGP SIGNATURE-----

Merge tag 'upstream/0.24.2'
2016-10-27 19:18:45 +11:00
Russell Sim
36e22e3307 Imported Upstream version 0.24.2 2016-10-27 19:07:53 +11:00
Arthur Schreiber
6d354747ac Perf: Don't perform merge operations for trivial merges.
When one side of a merge is treesame to the ancestor, we can take the other side and skip all the expensive merge operations. This optimization can only be performed when the generation of  REUC extension data is skipped.
2016-10-18 08:20:41 +02:00
Carlos Martín Nieto
67dd314086 Merge pull request #3966 from vivaladav/documentation-fixes
patch: minor documentation fix.
2016-10-16 12:57:29 +02:00
Davide Coppola
6d8ecf087c patch: minor documentation fix.
Fix @return description of git_patch_num_lines_in_hunk.
2016-10-16 00:43:27 +01:00
Igor Gnatenko
feb330d50d add support for OpenSSL 1.1.0 for BIO filter
Closes: https://github.com/libgit2/libgit2/issues/3959
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-10-12 12:41:43 +02:00
Patrick Steinhardt
dcd759b829 Merge pull request #3897 from pks-t/pks/squelch-example-warnings
Squelch example warnings, enable CI
2016-10-10 09:25:49 +02:00
Patrick Steinhardt
ec3f5a9c20 script: cibuild: build examples 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
fc29391950 examples: add: fix type casting warning 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
5c2a8361d7 examples: diff: parse correct types for line-diffopts 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
7314da1055 examples: fix warnings in network/fetch.c 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
e2d1b7ecbf examples: general: fix remaining warnings 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
662eee1541 examples: general: convert C99 comments to C90 comments 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
c313e3d986 examples: general: extract function demonstrating OID parsing 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
29d9afc0fb examples: general: extract function demonstrating ODB 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
b009adad35 examples: general: extract function demonstrating commit writing 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
15960454c5 examples: general: extract functions demonstrating object parsing 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
8b93ccdf08 examples: general: extract function demonstrating revwalking 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
c079e3c847 examples: general: extract function demonstrating index walking 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
f9a7973dd9 examples: general: extract function demonstrating reference listings 2016-10-10 09:04:41 +02:00