Commit Graph

10496 Commits

Author SHA1 Message Date
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
Edward Thomson
69723dd8d3 Merge pull request #3730 from andhe/fix-stream-test
tests: fix core/stream test when built with openssl off
2016-04-06 15:59:31 -04:00
Andreas Henriksson
04f47a43f9 tests: fix core/stream test when built with openssl off
When passing -DUSE_OPENSSL:BOOL=OFF to cmake the testsuite will
fail with the following error:

core::stream::register_tls [/tmp/libgit2/tests/core/stream.c:40]
  Function call failed: (error)
  error -1 - <no message>

Fix test to assume failure for tls when built without openssl.
While at it also fix GIT_WIN32 cpp to check if it's defined
or not.
2016-04-06 15:00:32 +02:00
Edward Thomson
54cfee6d88 Merge pull request #3728 from libgit2/cmn/no-embed
Remove Makefile.embed
2016-04-05 14:47:02 -04:00
Carlos Martín Nieto
21ba34618b Remove Makefile.embed
This has not been a supported build mode for quite some time, and it
correspondingly hasn't worked to build the library for a long time. Get
rid of it, as the only build mode we support is though CMakek.
2016-04-05 13:25:23 -04:00
Andreas Henriksson
b3ee20cb0a Imported Upstream version 0.24.0 2016-04-03 14:22:52 +02:00
Carlos Martín Nieto
381caf5690 Merge pull request #3724 from ethomson/submodule_start_supports_silly_slashes
iterator/diff: allow trailing `/` on start/end paths to match submodules
2016-04-02 22:19:42 -07:00
Edward Thomson
7018e3b747 Merge pull request #3723 from libgit2/cmn/ignore-symlink
ignore: don't use realpath to canonicalize path
2016-04-02 16:52:53 -04:00
Edward Thomson
d47f7e1c15 iterator: support trailing / in start for submod
Allow callers to specify a start path with a trailing slash to match
a submodule, instead of just a directory.  This is for some legacy
behavior that's sort of dumb, but there it is.
2016-04-02 13:34:55 -07:00
Edward Thomson
2e0391f4f1 diff: test submodules are found with trailing /
Test that submodules are found when the are included in a pathspec
but have a trailing slash.
2016-04-02 13:02:41 -07:00
Carlos Martín Nieto
d364dc8b39 ignore: don't use realpath to canonicalize path
If we're looking for a symlink, realpath will give us the resolved path,
which is not what we're after, but a canonicalized version of the path
the user asked for.
2016-04-02 21:32:28 +02:00
Carlos Martín Nieto
36fc25572c Merge pull request #3720 from pks-t/pks/merge-driver-memleaks
merge_driver: fix missing `goto done;`
2016-04-01 04:09:50 -07:00
Patrick Steinhardt
83c93a7cc2 merge_driver: fix missing goto done;
The code initializing the merge driver registry accidentally
forgot a `goto done` in case of an error. Because of this the
next line, which registers the global shutdown callback for the
merge drivers, is only called when an error occured.

Fix this by adding the missing `goto done`. This fixes some
memory leaks when the global state is shut down.
2016-04-01 09:37:55 +02:00
Carlos Martín Nieto
1cac688d3f Merge pull request #3719 from libgit2/ethomson/submodule_status
WD iterator: properly identify submodules
2016-04-01 00:29:51 -07:00
Edward Thomson
4df6ddaa1a iterator: use correct search function 2016-03-31 17:58:43 -04:00
Edward Thomson
74ab5f2cd0 status: test submodules with mixed case 2016-03-31 17:58:43 -04:00
Carlos Martín Nieto
24ecf18e81 Merge pull request #3717 from libgit2/ethomson/leaks
Plug some leaks
2016-03-31 14:04:43 -07:00
Edward Thomson
c4aa5c042c leaks: call xdl_free_classifier 2016-03-31 10:43:57 -04:00
Edward Thomson
17442b28f9 leaks: fix some leaks in the tests 2016-03-31 10:41:33 -04:00
Edward Thomson
9705483342 leaks: fix some iterator leaks 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
f5c874a475 Plug a few leaks 2016-03-31 10:41:33 -04:00
Edward Thomson
1694a63994 Merge pull request #3716 from libgit2/cmn/typedef-sizet
Add a no-op size_t typedef for the doc parser
2016-03-31 10:04:43 -04:00
Carlos Martín Nieto
d53cc13e3a Merge pull request #3575 from pmq20/master-13jan16
Remove duplicated calls to git_mwindow_close
2016-03-31 04:12:46 -07:00