Commit Graph

9093 Commits

Author SHA1 Message Date
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
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
Patrick Steinhardt
038d7af085 signature: use GITERR_CHECK_ALLOC to check for OOM situation
When checking for out of memory situations we usually use the
GITERR_CHECK_ALLOC macro. Besides conforming to our current code
base it adds the benefit of silencing errors in Coverity due to
Coverity handling the macro's error path as abort.
2016-02-18 20:50:33 +01:00
Patrick Steinhardt
40f6f22517 coverity: hint that string length is at least 2
When checking if a string is prefixed by a drive letter (e.g.
"C:") we verify this by inspecting the first and second character
of the string. Coverity thinks this is a defect as we do not
check the string's length first, but in fact we only check the
second character if the first character is part of the alphabet,
that is it cannot be '\0'.

Fix this by overriding the macro and explicitly checking the
string's length.
2016-02-18 20:50:33 +01:00
Patrick Steinhardt
5981ab1d70 coverity: add nodefs for abort macros
Add nodefs for macros that abort the current flow due to errors.
This includes macros that trigger on integer overflows and for
the version check macro. This aids Coverity as we point out that
these paths will cause a fatal error.
2016-02-18 20:50:33 +01:00
Carlos Martín Nieto
c1b75f05ad Merge pull request #3604 from ethomson/nsec_xplat
Handle `USE_NSECS`
2016-02-18 15:11:31 +01:00
Carlos Martín Nieto
b85d0afd6e Merge pull request #3606 from ethomson/drop_xp
win32: drop xp support in WideCharToMultiByte
2016-02-18 15:11:02 +01:00
Carlos Martín Nieto
5663d4f691 Merge pull request #3613 from ethomson/fixups
Remove most of the silly warnings
2016-02-18 12:31:56 +01:00
Carlos Martín Nieto
594a5d12d4 Merge pull request #3619 from ethomson/win32_forbidden
win32: allow us to read indexes with forbidden paths on win32
2016-02-18 12:28:06 +01:00
Carlos Martín Nieto
298d1b07af Merge pull request #3621 from pra85/patch-1
Fix a typo
2016-02-18 11:44:04 +01:00
Carlos Martín Nieto
9c26f90c37 PROJECTS: remove a few things we do have 2016-02-18 11:39:55 +01:00
Prayag Verma
d50bf71694 Fix a typo
`compatability` → `compatibility`
2016-02-18 13:26:08 +05:30
Edward Thomson
318b825e76 index: allow read of index w/ illegal entries
Allow `git_index_read` to handle reading existing indexes with
illegal entries.  Allow the low-level `git_index_add` to add
properly formed `git_index_entry`s even if they contain paths
that would be illegal for the current filesystem (eg, `AUX`).
Continue to disallow `git_index_add_bypath` from adding entries
that are illegal universally illegal (eg, `.git`, `foo/../bar`).
2016-02-17 13:10:33 +00:00
Edward Thomson
4fea9cffbd iterator: assert tree_iterator has a frame
Although a `tree_iterator` that failed to be properly created
does not have a frame, all other `tree_iterator`s should.  Do not
call `pop` in the failure case, but assert that in all other
cases there is a frame.
2016-02-17 13:10:33 +00:00
Colin Xu
a218b2f625 Validate pointer before access the member.
When Git repository at network locations, sometimes git_iterator_for_tree
fails at iterator__update_ignore_case so it goes to git_iterator_free.
Null pointer will crash the process if not check.

Signed-off-by: Colin Xu <colin.xu@gmail.com>
2016-02-17 13:10:33 +00:00
Edward Thomson
4be2aa57c9 win32: tests around handling forbidden paths
Introduce a repository that contains some paths that were illegal
on PC-DOS circa 1981 (like `aux`, `con`, `com1`) and that in a
bizarre fit of retrocomputing, remain illegal on some "modern"
computers, despite being "new technology".

Introduce some aspirational tests that suggest that we should be
able to cope with trees and indexes that contain paths that
would be illegal on the filesystem, so that we can at least diff
them.  Further ensure that checkout will not write a repository
with forbidden paths.
2016-02-17 13:10:33 +00:00
Carlos Martín Nieto
474bd2c160 Merge pull request #3617 from libgit2/cmn/extract-sig-errors
commit: expose the different kinds of errors
2016-02-16 14:45:32 +01:00
Carlos Martín Nieto
eadd0f05f6 commit: expose the different kinds of errors
We should be checking whether the object we're looking up is a commit,
and we should let the caller know whether the not-found return code
comes from a bad object type or just a missing signature.
2016-02-16 14:06:48 +01:00
Edward Thomson
9ce0399c4d winhttp: use an unsigned iterator 2016-02-16 11:50:49 +00:00
Edward Thomson
3b2fa0fb36 submodule: explicitly cast to the teensy time value 2016-02-16 11:50:48 +00:00
Edward Thomson
b2ca8d9c29 index: explicitly cast the teeny index entry members 2016-02-16 11:50:47 +00:00
Edward Thomson
997e030154 index: don't use seek return as an error code 2016-02-16 11:50:47 +00:00
Edward Thomson
9a634cba85 index: explicitly cast new hash size to an int 2016-02-16 11:50:46 +00:00
Edward Thomson
0d9a39eaf5 win32: drop incorrect constness 2016-02-16 11:50:45 +00:00
Edward Thomson
c4d23928c3 fstat: use our custom stat 2016-02-16 11:50:45 +00:00
Edward Thomson
aadad40592 tree: zap warnings around size_t vs uint16_t 2016-02-16 11:50:44 +00:00
Carlos Martín Nieto
1aa1492182 Merge pull request #3615 from ethomson/rebase_bare
rebase: persist a single in-memory index
2016-02-16 08:54:43 +01:00
Edward Thomson
f28bae0c38 rebase: persist a single in-memory index
When performing an in-memory rebase, keep a single index for the
duration, so that callers have the expected index lifecycle and
do not hold on to an index that is free'd out from under them.
2016-02-15 19:27:06 +00:00
Edward Thomson
35439f5997 win32: introduce p_timeval that isn't stupid
Windows defines `timeval` with `long`, which we cannot
sanely cope with.  Instead, use a custom timeval struct.
2016-02-12 10:34:15 -08:00
Carlos Martín Nieto
5a296ad07e Merge pull request #3610 from ethomson/rebase_bare
rebase: introduce bare rebasing
2016-02-12 00:55:20 +01:00