Commit Graph

10765 Commits

Author SHA1 Message Date
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
Edward Thomson
bbd65ad27e tests: skip the unreadable file tests as root
When running as root, skip the unreadable file tests, because, well,
they're probably _not_ unreadable to root unless you've got some
crazy NSA clearance-level honoring operating system shit going on.
2016-04-11 15:32:38 -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
0e00eecf83 Merge pull request #3736 from libgit2/cmn/dwim-general-message
refs: provide a more general error message for dwim
2016-04-11 13:29:54 -04:00
Carlos Martín Nieto
b93b74b9e3 Merge pull request #3737 from ethomson/strict-object
Strict object creation in `refs::create`
2016-04-11 19:24:47 +02:00
Edward Thomson
d22a8b9583 refs::create: strict object creation on by default
When we turned strict object creation validation on by default, we
forgot to inform the refs::create tests of this.  They, in fact,
believed that strict object creation was off by default.  As a result,
their cleanup function went and turned strict object creation off for
the remaining tests.
2016-04-11 11:50:11 -04:00
Carlos Martín Nieto
6d22ef7a51 reset: use real ids for the tests
This lets us run with strict object creation on.
2016-04-11 11:47:56 -04:00
Carlos Martín Nieto
77965c685d refs: provide a more general error message for dwim
If we cannot dwim the input, set the error message to be explicit about
that. Otherwise we leave the error for the last failed lookup, which
can be rather unexpected as it mentions a remote when the user thought
they were trying to look up a branch.
2016-04-11 17:47:03 +02:00
Andreas Henriksson
918b73d561 Release to experimental 2016-04-11 17:09:53 +02:00
Andreas Henriksson
aacc6f5f4c Update debian/changelog 2016-04-11 10:48:27 +02:00
Andreas Henriksson
267c427582 Disable fakeroot emulation when running tests
- tests only works under regular user or real root.

Git-Dch: Full
2016-04-11 10:48:18 +02:00
Andreas Henriksson
fee1094301 Add git_tests-fix-core-stream-test-when-built-with-openssl-o.patch 2016-04-11 10:48:13 +02:00