libgit2/src
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
..
hash hash_generic: __extension__ keyword for pedantry 2015-02-04 15:26:09 -05:00
transports transports: http: reset connected flag when closing transport 2016-08-17 11:41:30 +02:00
unix Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
win32 Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
xdiff leaks: call xdl_free_classifier 2016-03-31 10:43:57 -04:00
annotated_commit.c annotated_commit: provide refs and description 2016-04-26 13:19:58 -04:00
annotated_commit.h annotated_commit: provide refs and description 2016-04-26 13:19:58 -04:00
apply.c diff: treat binary patches with no data special 2016-09-05 12:26:47 -05:00
apply.h Introduce git_apply_patch 2016-05-26 11:36:11 -05:00
array.h Introduce git_apply_patch 2016-05-26 11:36:11 -05:00
attr_file.c attr_file: fix resource leak 2016-02-09 11:11:38 +01:00
attr_file.h Improvements to ignore performance on Windows. 2015-04-28 14:24:58 -04:00
attr.c attr: always return errors 2015-05-12 14:39:49 -04:00
attr.h Attribute file cache refactor 2014-04-17 14:56:41 -07:00
attrcache.c pool: Simplify implementation 2015-10-28 10:13:13 +01:00
attrcache.h attrcache: don't re-read attrs during checkout 2015-02-03 00:31:08 -05:00
bitvec.h Address PR comments 2014-02-20 14:27:10 -08:00
blame_git.c blame: do not decrement commit refcount in make_origin 2016-06-29 14:43:00 +02:00
blame_git.h blame: guard xdiff calls for large files 2015-10-05 22:59:53 +02:00
blame.c blame: handle error when resoling HEAD in normalize_options 2016-03-11 14:20:15 +01:00
blame.h blame: use size_t for line counts in git_blame__entry 2015-12-01 09:02:47 +01:00
blob.c blob: remove _fromchunks() 2016-03-22 20:00:25 +01:00
blob.h Fix rename detection to use actual blob size 2013-07-25 12:27:39 -07:00
branch.c annotated_commit: provide refs and description 2016-04-26 13:19:58 -04:00
branch.h branch: rename 'tracking' to 'upstream' 2013-03-30 15:45:57 +01:00
buf_text.c git_buf_text_lf_to_crlf: allow mixed line endings 2015-06-22 12:00:23 -04:00
buf_text.h git_buf_text_lf_to_crlf: allow mixed line endings 2015-06-22 12:00:23 -04:00
buffer.c git_buf_quote/unquote: handle > \177 2016-05-26 13:01:07 -05:00
buffer.h git_buf_quote: quote ugly characters 2016-05-26 13:01:06 -05:00
cache.c Fix #3094 - improve use of portable size_t/ssize_t format specifiers. 2015-07-12 19:55:19 +02:00
cache.h Refactor git_cache to use an rwlock 2014-08-26 15:12:43 -07:00
cc-compat.h There is no "z" size specifier on MSVC 2014-10-13 16:32:26 +02:00
checkout.c checkout: don't try to calculate oid for directories 2016-09-14 10:28:24 +01:00
checkout.h iterator: submodules are determined by an index or tree 2014-11-07 08:33:27 +01:00
cherrypick.c cherrypick, revert: drop unnecessary SAFE_CREATE 2015-02-27 13:47:30 -05:00
clone.c Remove unused static functions 2016-06-21 07:58:33 +02:00
clone.h clone: add flags to override whether to perform a local clone 2014-05-28 15:40:22 +02:00
commit_list.c commit_list: fix the date comparison function 2016-10-06 11:04:55 +02:00
commit_list.h revwalk: get closer to git 2016-10-06 11:04:55 +02:00
commit.c commit: always initialize commit message 2016-10-09 13:26:21 +02:00
commit.h commit: introduce git_commit_body 2015-12-01 10:07:00 +01:00
common.h win32: rename pthread.{c,h} to thread.{c,h} 2016-06-20 19:50:18 +02:00
config_cache.c config_cache: check return value of git_config__lookup_entry 2016-03-11 14:20:15 +01:00
config_file.c Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
config_file.h config: implement basic transactional support 2015-08-12 04:09:09 +02:00
config.c Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
config.h config: add a ProgramData level 2015-10-21 15:11:18 +02:00
crlf.c crlf: set a safe crlf default 2016-07-24 16:10:30 -04:00
curl_stream.c curl: ask for proxy credentials 2016-04-19 13:54:19 +02:00
curl_stream.h curl: remove the encrypted param to the constructor 2015-06-24 17:26:36 +02:00
date.c Introduce git__date_rfc2822_fmt. Allows for RFC2822 date headers 2014-04-11 21:55:35 +02:00
delta.c delta: refactor git_delta functions for consistency 2016-05-26 13:01:03 -05:00
delta.h delta: refactor git_delta functions for consistency 2016-05-26 13:01:03 -05:00
describe.c git_object_dup: introduce typesafe versions 2016-03-23 17:08:37 -04:00
diff_driver.c Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
diff_driver.h Initial take on builtin drivers with multiline 2014-01-24 10:43:05 -08:00
diff_file.c git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
diff_file.h diff: introduce binary diff callbacks 2015-06-12 09:39:20 -04:00
diff_generate.c Teach git_patch_from_diff about parsed diffs 2016-08-24 09:08:57 -05:00
diff_generate.h git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
diff_parse.c Teach git_patch_from_diff about parsed diffs 2016-08-24 09:08:57 -05:00
diff_parse.h Teach git_patch_from_diff about parsed diffs 2016-08-24 09:08:57 -05:00
diff_print.c diff: treat binary patches with no data special 2016-09-05 12:26:47 -05:00
diff_stats.c Merge branch 'pr/3809' 2016-10-09 16:05:48 +01:00
diff_tform.c git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
diff_tform.h git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
diff_xdiff.c patch: patch_diff -> patch_generated 2016-05-26 13:01:08 -05:00
diff_xdiff.h patch: patch_diff -> patch_generated 2016-05-26 13:01:08 -05:00
diff.c introduce git_diff_from_buffer to parse diffs 2016-05-26 13:01:09 -05:00
diff.h Teach git_patch_from_diff about parsed diffs 2016-08-24 09:08:57 -05:00
errors.c errors: tighten up git_error_state OOMs a bit more 2015-08-03 19:44:51 -04:00
fetch.c Rename FALLBACK to UNSPECIFIED 2015-06-25 12:48:44 +02:00
fetch.h Fix #3093 - remove declaration of unused function git_fetch__download_pack 2015-06-30 16:48:47 -04:00
fetchhead.c fetchhead: deal with quotes in branch names 2014-04-24 14:08:29 +02:00
fetchhead.h Join typedef and struct definitions in single file. 2014-09-24 11:00:51 +02:00
filebuf.c filebuf: fix uninitialized warning 2016-06-01 10:03:52 -05:00
filebuf.h filebuf: allow using a custom buffer size 2016-03-22 19:34:08 +01:00
fileops.c odb: only freshen pack files every 2 seconds 2016-08-04 15:12:04 -04:00
fileops.h odb: only freshen pack files every 2 seconds 2016-08-04 15:12:04 -04:00
filter.c filter: avoid races during filter registration 2016-02-08 16:31:42 -08:00
filter.h filter: avoid races during filter registration 2016-02-08 16:31:42 -08:00
fnmatch.c ignore: move star-star matching closer to it use 2016-04-19 19:39:06 +02:00
fnmatch.h Restore attributions for fnmatch 2014-05-19 14:39:45 +01:00
global.c mwindow: init mwindow files in git_libgit2_init 2016-08-04 10:30:48 -04:00
global.h Setup better defaults for OpenSSL ciphers 2016-03-14 12:07:13 +00:00
graph.c graph: fix ahead-behind logic 2014-08-28 13:36:58 +02:00
hash.c
hash.h hash: use CommonCrypto on OSX for SHA-1 2014-10-24 13:31:18 +02:00
hashsig.c diff_tform: account for whitespace options 2015-03-04 00:01:34 -05:00
ident.c Fix ident replacement to match Git behavior 2015-05-26 19:56:06 +02:00
idxmap.h index: Also size-hint the hash table 2015-12-16 19:36:50 +01:00
ignore.c ignore: allow unignoring basenames in subdirectories 2016-08-12 14:47:54 +02:00
ignore.h Improvements to ignore performance on Windows. 2015-04-28 14:24:58 -04:00
index.c index: support index v4 2016-08-10 14:19:30 -04:00
index.h index: support index v4 2016-08-10 14:19:30 -04:00
indexer.c Merge pull request #3575 from pmq20/master-13jan16 2016-03-31 04:12:46 -07:00
integer.h Fix MAX 32 bit build problem described in libgit2/libgit2#2917 2015-02-20 18:59:43 +01:00
iterator.c filesystem_iterator: fixed double free on error 2016-08-22 09:27:47 -06:00
iterator.h iterator: cleanups 2016-03-24 15:59:49 -04:00
khash.h khash: add eol so picky compilers stop warning 2015-07-10 09:53:31 -05:00
map.h Fix compiler warning (git_off_t cast to size_t). 2014-05-19 17:37:29 -07:00
merge_driver.c merge_driver: fix missing goto done; 2016-04-01 09:37:55 +02:00
merge_driver.h merge driver: remove check callback 2016-03-17 11:06:00 -04:00
merge_file.c merge_file: do not unnecessarily check ours/theirs for NULL 2016-05-02 17:45:23 +02:00
merge.c git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
merge.h merge driver: remove check callback 2016-03-17 11:06:00 -04:00
message.c message: don't assume the comment char 2014-05-18 10:06:49 +02:00
message.h
mwindow.c mwindow: init mwindow files in git_libgit2_init 2016-08-04 10:30:48 -04:00
mwindow.h mwindow: init mwindow files in git_libgit2_init 2016-08-04 10:30:48 -04:00
netops.c netops: make the path optional in URLs 2016-04-19 13:54:19 +02:00
netops.h Drop extra_http_headers from git_remote 2015-09-08 14:01:57 -04:00
notes.c iterator: use an options struct instead of args 2015-08-28 18:39:47 -04:00
notes.h Introduce git_note_author, git_note_committer 2014-10-26 22:59:29 -04:00
object_api.c git_object_dup: introduce typesafe versions 2016-03-23 17:08:37 -04:00
object.c object: avoid call of memset with ouf of bounds pointer 2016-03-11 12:14:01 +01:00
object.h git_object__is_valid: use odb_read_header 2016-02-28 18:54:39 -05:00
odb_loose.c odb: only freshen pack files every 2 seconds 2016-08-04 15:12:04 -04:00
odb_mempack.c mempack: expose clear function 2015-09-11 20:06:14 -04:00
odb_pack.c odb: only freshen pack files every 2 seconds 2016-08-04 15:12:04 -04:00
odb.c odb: only provide the empty tree 2016-08-05 19:30:56 -04:00
odb.h odb: improved not found error messages 2016-03-07 10:20:01 -05:00
offmap.h Remove extra semicolon outside of a function 2015-02-15 21:07:05 +01:00
oid.c git__*allocarray: safer realloc and malloc 2015-02-12 22:54:47 -05:00
oid.h git_odb_exists_many_prefixes: query odb for multiple short ids 2016-03-07 16:10:25 -05:00
oidarray.c merge: expose multiple merge bases 2014-07-27 17:17:22 +02:00
oidarray.h merge: expose multiple merge bases 2014-07-27 17:17:22 +02:00
oidmap.h mempack: expose clear function 2015-09-11 20:06:14 -04:00
openssl_stream.c openssl_stream: fix typo 2016-10-31 13:50:23 +01:00
openssl_stream.h global: make openssl registration like the rest 2016-02-08 16:30:39 -08:00
pack-objects.c packbuilder: size_t all the things 2016-07-24 15:49:19 -04:00
pack-objects.h packbuilder: size_t all the things 2016-07-24 15:49:19 -04:00
pack.c pack: fix race in pack_entry_find_offset 2016-11-02 12:23:12 +01:00
pack.h odb: only freshen pack files every 2 seconds 2016-08-04 15:12:04 -04:00
patch_generate.c diff: treat binary patches with no data special 2016-09-05 12:26:47 -05:00
patch_generate.h Teach git_patch_from_diff about parsed diffs 2016-08-24 09:08:57 -05:00
patch_parse.c diff: treat binary patches with no data special 2016-09-05 12:26:47 -05:00
patch_parse.h Teach git_patch_from_diff about parsed diffs 2016-08-24 09:08:57 -05:00
patch.c patch: error on diff callback failure 2016-09-02 11:22:33 -05:00
patch.h git_patch_parse_ctx: refcount the context 2016-05-26 13:01:08 -05:00
path.c Patch parsing from patch files 2016-05-26 11:36:11 -05:00
path.h Patch parsing from patch files 2016-05-26 11:36:11 -05:00
pathspec.c iterator: disambiguate reset and reset_range 2016-03-23 17:08:37 -04:00
pathspec.h Add git_pathspec_match_diff API 2013-07-10 20:50:33 +02:00
pool.c Add a new build flag to disable the pool allocator and pass all git_pool_malloc calls straight to git__malloc 2016-01-12 16:08:38 -05:00
pool.h pool: provide macro to statically initialize git_pool 2016-08-05 10:57:13 +02:00
posix.c Split the page size from the mmap alignment 2016-03-16 21:36:25 +01:00
posix.h Split the page size from the mmap alignment 2016-03-16 21:36:25 +01:00
pqueue.c pqueue: resolve possible NULL pointer dereference 2016-10-28 16:19:24 +02:00
pqueue.h vector, pqueue: add git_vector_reverse and git_pqueue_reverse 2016-10-06 11:04:55 +02:00
proxy.c proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
proxy.h proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
push.c proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
push.h Tell the git_transport about the custom_headers 2015-09-08 14:02:33 -04:00
rebase.c rebase: don't ask for time sorting 2016-10-06 11:04:55 +02:00
refdb_fs.c refdb_fs: fail if refcache returns NULL pointer 2016-03-11 14:20:15 +01:00
refdb_fs.h immutable references and a pluggable ref database 2013-03-07 11:01:52 -06:00
refdb.c refdb and odb backends must provide free function 2015-10-01 00:50:37 +02:00
refdb.h Introduce reference transactions 2014-09-30 15:44:32 +02:00
reflog.c Fix wrong format string in git_reflog_drop() error message 2015-04-24 23:56:59 +08:00
reflog.h reflog: move the reflog implementation into refdb_fs 2013-10-02 06:53:24 +02:00
refs.c Allow creating copies of git_reference objects. 2016-04-22 10:34:17 -07:00
refs.h repository: distinguish sequencer cherry-pick and revert 2015-11-20 13:19:23 -05:00
refspec.c refspec: do not set empty rhs for fetch refspecs 2016-08-04 13:54:19 +02:00
refspec.h refspec: git_refspec_parse() does not exist 2014-04-01 20:18:36 +02:00
remote.c remote: Handle missing config values when deleting a remote 2016-07-15 13:47:01 -04:00
remote.h Drop extra_http_headers from git_remote 2015-09-08 14:01:57 -04:00
repo_template.h Make mode handling during init more like git 2013-02-27 13:44:15 -08:00
repository.c repository: don't cast to int for no reason 2016-07-24 15:49:19 -04:00
repository.h submodule: remove the per-repo cache 2015-06-22 17:02:54 +02:00
reset.c annotated_commit: provide refs and description 2016-04-26 13:19:58 -04:00
revert.c cherrypick, revert: drop unnecessary SAFE_CREATE 2015-02-27 13:47:30 -05:00
revparse.c Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
revwalk.c revwalk: don't show commits that become uninteresting after being enqueued 2016-10-06 18:13:34 +02:00
revwalk.h Reorder some khash declarations 2015-03-11 02:36:11 +01:00
settings.c Merge pull request #3850 from wildart/custom-tls 2016-08-04 12:45:19 -04:00
sha1_lookup.c Backport @peff's fix for duplicates in sha1_lookup 2013-09-04 13:16:57 +02:00
sha1_lookup.h sha1_lookup: do not use the "experimental" lookup mode 2013-08-14 10:28:01 +02:00
signature.c Introduce git_signature_from_buffer 2016-04-28 12:47:14 -04:00
signature.h Introduce git_rebase_commit 2014-10-26 22:59:19 -04:00
socket_stream.c stream: constify the write buffer 2014-12-10 16:20:52 +01:00
socket_stream.h Add an OpenSSL IO stream 2014-12-10 01:17:41 +01:00
sortedcache.c pool: Simplify implementation 2015-10-28 10:13:13 +01:00
sortedcache.h Add stddef include for sortedcache 2013-08-28 11:20:47 -07:00
stash.c git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
status.c git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
status.h Rename diff objects and split patch.h 2013-10-11 14:51:54 -07:00
stransport_stream.c stransport: do not use git_stream_free on uninitialized stransport 2016-08-09 08:38:54 +02:00
stransport_stream.h Add a SecureTransport TLS channel 2015-04-23 17:39:51 +02:00
stream.h net: use proxy options struct in the stream config 2016-04-19 13:54:19 +02:00
strmap.c config: get rid of a useless asignment 2013-08-12 11:40:57 +02:00
strmap.h Remove extra semicolon outside of a function 2015-02-15 21:07:05 +01:00
strnlen.h strnlen() is only available from Visual Studio 2005+ 2014-07-06 09:22:24 +02:00
submodule.c submodule: Try to fetch when update fails to find the target commit in the submodule. 2016-06-28 16:08:58 -06:00
submodule.h submodule: handle writing out all enum values for settings 2015-06-22 17:02:56 +02:00
sysdir.c sysdir: use the standard init pattern 2016-08-04 12:26:06 -04:00
sysdir.h sysdir: use the standard init pattern 2016-08-04 12:26:06 -04:00
tag.c tag: ignore extra header fields 2016-04-25 12:18:32 +02:00
tag.h Simplify object table parse functions 2013-04-22 16:52:06 +02:00
thread-utils.c Fix macro redefinition warning 2015-07-15 11:40:06 +01:00
thread-utils.h win32: rename pthread.{c,h} to thread.{c,h} 2016-06-20 19:50:18 +02:00
tls_stream.c stream: allow registering a user-provided TLS constructor 2015-11-03 08:10:29 -08:00
tls_stream.h Abstract away the TLS stream implementation 2015-04-23 17:39:51 +02:00
trace.c Remove trace / add git_diff_perfdata struct + api 2014-05-02 09:21:33 -07:00
trace.h Variadic macros is only available from Visual Studio 2005+ 2014-07-06 09:22:24 +02:00
transaction.c pool: Simplify implementation 2015-10-28 10:13:13 +01:00
transaction.h config: perform unlocking via git_transaction 2015-08-12 04:09:38 +02:00
transport.c Merge pull request #3869 from richardipsum/fix-outdated-comment 2016-08-04 13:20:49 -04:00
tree-cache.c tree-cache: correct the entry_count calculation 2014-10-22 21:25:08 +02:00
tree-cache.h index: write out the tree cache extension 2014-10-10 19:43:42 +02:00
tree.c tree: validate filename and OID length when parsing object 2016-10-07 09:18:55 +02:00
tree.h tree: drop the now-unnecessary entries vector 2016-03-22 06:21:13 -07:00
tsort.c git__*allocarray: safer realloc and malloc 2015-02-12 22:54:47 -05:00
userdiff.h Update the javascript diff driver's function pattern. 2014-10-09 22:21:34 +02:00
util.c time: Export git_time_monotonic 2016-09-13 15:52:43 +02:00
util.h Patch parsing from patch files 2016-05-26 11:36:11 -05:00
varint.c varint: Add varint encoding/decoding 2016-08-10 14:19:06 -04:00
varint.h varint: Add varint encoding/decoding 2016-08-10 14:19:06 -04:00
vector.c vector, pqueue: add git_vector_reverse and git_pqueue_reverse 2016-10-06 11:04:55 +02:00
vector.h vector, pqueue: add git_vector_reverse and git_pqueue_reverse 2016-10-06 11:04:55 +02:00
zstream.c zstream: fail when asked to inflate garbage 2016-05-26 13:01:04 -05:00
zstream.h zstream: offer inflating, git_zstream_inflatebuf 2016-05-26 13:01:03 -05:00