Commit Graph

9196 Commits

Author SHA1 Message Date
Carlos Martín Nieto
fe1f47776f Add a no-op size_t typedef for the doc parser
Clang's documentation parser, which we use in our documentation system
does not report any comments for functions which use size_t as a type.

The root cause is buried somewhere in libclang but we can work around it
by defining the type ourselves. This typedef makes sure that libclang
sees it and that we do not change its size.
2016-04-11 15:58:57 -04:00
Patrick Steinhardt
56da07cbcb xdiff/xprepare: fix a memory leak
The xdl_prepare_env() function may initialise an xdlclassifier_t
data structure via xdl_init_classifier(), which allocates memory
to several fields, for example 'rchash', 'rcrecs' and 'ncha'.
If this function later exits due to the failure of xdl_optimize_ctxs(),
then this xdlclassifier_t structure, and the memory allocated to it,
is not cleaned up.

In order to fix the memory leak, insert a call to xdl_free_classifier()
before returning.

This patch was originally written by Ramsay Jones (see commit
87f16258367a3b9a62663b11f898a4a6f3c19d31 in git.git).
2016-04-11 15:58:57 -04:00
Patrick Steinhardt
3ec0f2e37d xdiff/xprepare: use the XDF_DIFF_ALG() macro to access flag bits
Commit 307ab20b3 ("xdiff: PATIENCE/HISTOGRAM are not independent option
bits", 19-02-2012) introduced the XDF_DIFF_ALG() macro to access the
flag bits used to represent the diff algorithm requested. In addition,
code which had used explicit manipulation of the flag bits was changed
to use the macros.

However, one example of direct manipulation remains. Update this code to
use the XDF_DIFF_ALG() macro.

This patch was originally written by Ramsay Jones (see commit
5cd6978a9cfef58de061a9525f3678ade479564d in git.git).
2016-04-11 15:58:57 -04:00
Carlos Martín Nieto
c86a65be4c config: don't special-case multivars that don't exist yet
This special-casing ignores that we might have a locked file, so the
hashtable does not represent the contents of the file we want to
write. This causes multivar writes to overwrite entries instead of add
to them when under lock.

There is no need for this as the normal code-path will write to the file
just fine, so simply get rid of it.
2016-04-11 15:58:57 -04:00
Carlos Martin Nieto
a1cf26448a win32: free thread-local data on thread exit 2016-04-11 15:58:57 -04:00
Carlos Martín Nieto
e97d2d7000 commit: fix extraction of single-line signatures
The function to extract signatures suffers from a similar bug to the
header field finding one by having an unecessary line feed check as a
break condition of its loop.

Fix that and add a test for this single-line signature situation.
2016-04-11 15:58:57 -04:00
Carlos Martín Nieto
d8fcafb2ca Split the page size from the mmap alignment
While often similar, these are not the same on Windows. We want to use the page
size on Windows for the pools, but for mmap we need to use the allocation
granularity as the alignment.

On the other platforms these values remain the same.
2016-04-11 15:58:56 -04:00
Marc Strapetz
9a668abd34 Option "LIBGIT2_PREFIX" to set the CMAKE's TARGET_PROPERTIES PREFIX
This is especially useful in combination with MinGW to yield the
Windows-compliant DLL name "git2.dll" instead of "libgit2.dll"
2016-04-11 15:58:56 -04:00
Marc Strapetz
f587f38c08 CMake: do not overwrite but only append to CMAKE_C_FLAGS_DEBUG
This is useful to force "smart" IDEs (like CLIon) to use debug
flag -g even it may have decided that "-D_DEBUG" (which is
already present) is sufficient.
2016-04-11 15:58:56 -04:00
Dirkjan Bussink
cdde081b35 Use general cl_git_fail because the error is generic 2016-04-11 15:58:56 -04:00
Dirkjan Bussink
4e91020c85 Start error string with lower case character 2016-04-11 15:58:56 -04:00
Dirkjan Bussink
c1ec732f46 Setup better defaults for OpenSSL ciphers
This ensures that when using OpenSSL a safe default set of ciphers
is selected. This is done so that the client communicates securely
and we don't accidentally enable unsafe ciphers like RC4, or even
worse some old export ciphers.

Implements the first part of https://github.com/libgit2/libgit2/issues/3682
2016-04-11 15:58:56 -04:00
Patrick Steinhardt
89e7604c3a config_cache: check return value of git_config__lookup_entry
Callers of `git_config__cvar` already handle the case where the
function returns an error due to a failed configuration variable
lookup, but we are actually swallowing errors when calling
`git_config__lookup_entry` inside of the function.

Fix this by returning early when `git_config__lookup_entry`
returns an error. As we call `git_config__lookup_entry` with
`no_errors == false` which leads us to call `get_entry` with
`GET_NO_MISSING` we will not return early when the lookup fails
due to a missing entry. Like this we are still able to set the
default value of the cvar and exit successfully.
2016-04-11 15:58:56 -04:00
Patrick Steinhardt
18c4ae70d1 filebuf: handle write error in lock_file
When writing to a file with locking not check if writing the
locked file actually succeeds. Fix the issue by returning error
code and message when writing fails.
2016-04-11 15:58:56 -04:00
Patrick Steinhardt
f17ed63759 blame: handle error when resoling HEAD in normalize_options
When normalizing options we try to look up HEAD's OID. While this
action may fail in malformed repositories we never check the
return value of the function.

Fix the issue by converting `normalize_options` to actually
return an error and handle the error in `git_blame_file`.
2016-04-11 15:58:56 -04:00
Patrick Steinhardt
dd78d7d15b blame_git: handle error returned by git_commit_parent 2016-04-11 15:58:55 -04:00
Patrick Steinhardt
8d3ee96ada 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-04-11 15:58:55 -04:00
Patrick Steinhardt
0b357e2eed coverity: report errors when uploading tarball
Curl by default does not report errors by setting the error code.
As the upload can fail through several conditions (e.g. the rate
limit, leading to unauthorized access) we should indicate this
information in Travis CI.

To improve upon the behavior, use `--write-out=%{http_code}` to
write out the HTTP code in addition to the received body and
return an error if the code does not equal 201.
2016-04-11 15:58:55 -04:00
Patrick Steinhardt
851c51abdf 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-04-11 15:58:55 -04:00
Patrick Steinhardt
d96c063852 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-04-11 15:58:55 -04:00
Patrick Steinhardt
1a16e8b057 pack-objects: fix memory leak on overflow 2016-04-11 15:58:55 -04:00
Patrick Steinhardt
e114bbac89 index: assert required OID are non-NULL 2016-04-11 15:58:55 -04:00
Patrick Steinhardt
d0780b8133 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-04-11 15:58:55 -04:00
Edward Thomson
fa4b93a61c backport git_oid__cpy_prefix 2016-04-11 15:58:54 -04:00
Patrick Steinhardt
faf823dcca tests: transport: fix memory leaks with registering transports 2016-04-11 14:15:28 -04:00
Piet Brauer
0370dae1ad Check for __CLANG_INTTYPES_H
This fixes an issue in Xcode 7.3 in objective-git where we get the error
"Include of non-modular header file in module". Not importing this
header again fixes the issue.
2016-04-11 14:14:32 -04:00
Patrick Steinhardt
e39ad747f7 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-04-11 14:14:25 -04:00
Patrick Steinhardt
ffb1f41949 describe: handle error code returned by git_pqueue_insert 2016-04-11 14:14:15 -04:00
Carlos Martín Nieto
4ebf745f06 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-04-11 14:13:34 -04:00
Chris Hescock
9ee498e800 Only buffer if necessary. 2016-04-11 14:13:11 -04:00
Edward Thomson
eb09ead246 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-04-11 14:12:40 -04:00
P.S.V.R
cdded6309a Remove duplicated calls to git_mwindow_close 2016-04-11 14:11:55 -04:00
Chris Hescock
e3862c9fb2 Buffer sideband packet data
The inner packet may be split across multiple sideband packets.
2016-04-11 14:11:51 -04:00
Yong Li
8ec3d88f58 Avoid subtraction overflow in git_indexer_commit 2016-04-11 14:11:41 -04:00
Chris Bargren
4a93a7fcc4 Tabs 2016-04-11 14:11:33 -04:00
Chris Bargren
b8dc15f70e Adding test cases that actually test the functionality of the new transport
ssh, ssh+git and git+ssh should all successfully build an SSH transport
2016-04-11 14:11:28 -04:00
Chris Bargren
e44f6586ce Removing #define for SSH_PREFIX_COUNT and using ARRAY_SIZE instead
Also moving var declarations to top of blocks to support bad old compilers
2016-04-11 14:11:11 -04:00
Chris Bargren
429155d516 Updating change to http_parser to reflect PR for nodejs/http-parser
The parser now also supports digits, '-' and '.'. https://github.com/nodejs/http-parser/pull/276
2016-04-11 14:11:06 -04:00
Chris Bargren
fa8b1a8822 Adding spec coverage for ssh+git and git+ssh protocols 2016-04-11 14:11:00 -04:00
Chris Bargren
ff8e3f0e6b Handle git+ssh:// and ssh+git:// protocols support 2016-04-11 14:10:55 -04:00
Chris Bargren
2f2575c002 Updating http parser to accept a + in the schema 2016-04-11 14:10:51 -04:00
Edward Thomson
785d8c48ea Merge pull request #3653 from libgit2/cmn/treebuilder-submodule
treebuilder: don't try to verify submodules exist in the odb
2016-03-04 13:50:23 +00: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
Edward Thomson
1609983377 Merge pull request #3651 from libgit2/cmn/init-libssh2
ssh: initialize libssh2
2016-03-03 22:57:45 +00: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
839bdb05a0 Merge pull request #3639 from srajko/threading-openssl-libssh2
Expand OpenSSL and libssh2 thread safety documentation
2016-03-03 21:20:33 +01:00
Carlos Martín Nieto
e23efa6ddf tests: take the version from our define 2016-03-03 21:03:10 +01:00
Carlos Martín Nieto
1e8255a39b Bump version to 0.24.0 2016-03-03 20:20:43 +01:00
Carlos Martín Nieto
c21c8f67e8 CHANGELOG: prepre tamplate for release 2016-03-03 20:18:55 +01:00
Carlos Martín Nieto
a7ef27af1c CHANGELOG: add note about WinHTTP cred handling 2016-03-03 20:17:13 +01:00