Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
5091aff7
Commit
5091aff7
authored
Feb 20, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2907 from jasonhaslam/git_packfile_unpack_race
Fix race in git_packfile_unpack.
parents
d15884ce
8588cb0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
src/pack.c
+9
-2
No files found.
src/pack.c
View file @
5091aff7
...
@@ -56,6 +56,7 @@ static git_pack_cache_entry *new_cache_object(git_rawobj *source)
...
@@ -56,6 +56,7 @@ static git_pack_cache_entry *new_cache_object(git_rawobj *source)
if
(
!
e
)
if
(
!
e
)
return
NULL
;
return
NULL
;
git_atomic_inc
(
&
e
->
refcount
);
memcpy
(
&
e
->
raw
,
source
,
sizeof
(
git_rawobj
));
memcpy
(
&
e
->
raw
,
source
,
sizeof
(
git_rawobj
));
return
e
;
return
e
;
...
@@ -145,7 +146,11 @@ static void free_lowest_entry(git_pack_cache *cache)
...
@@ -145,7 +146,11 @@ static void free_lowest_entry(git_pack_cache *cache)
}
}
}
}
static
int
cache_add
(
git_pack_cache
*
cache
,
git_rawobj
*
base
,
git_off_t
offset
)
static
int
cache_add
(
git_pack_cache_entry
**
cached_out
,
git_pack_cache
*
cache
,
git_rawobj
*
base
,
git_off_t
offset
)
{
{
git_pack_cache_entry
*
entry
;
git_pack_cache_entry
*
entry
;
int
error
,
exists
=
0
;
int
error
,
exists
=
0
;
...
@@ -171,6 +176,8 @@ static int cache_add(git_pack_cache *cache, git_rawobj *base, git_off_t offset)
...
@@ -171,6 +176,8 @@ static int cache_add(git_pack_cache *cache, git_rawobj *base, git_off_t offset)
assert
(
error
!=
0
);
assert
(
error
!=
0
);
kh_value
(
cache
->
entries
,
k
)
=
entry
;
kh_value
(
cache
->
entries
,
k
)
=
entry
;
cache
->
memory_used
+=
entry
->
raw
.
len
;
cache
->
memory_used
+=
entry
->
raw
.
len
;
*
cached_out
=
entry
;
}
}
git_mutex_unlock
(
&
cache
->
lock
);
git_mutex_unlock
(
&
cache
->
lock
);
/* Somebody beat us to adding it into the cache */
/* Somebody beat us to adding it into the cache */
...
@@ -702,7 +709,7 @@ int git_packfile_unpack(
...
@@ -702,7 +709,7 @@ int git_packfile_unpack(
* long as it's not already the cached one.
* long as it's not already the cached one.
*/
*/
if
(
!
cached
)
if
(
!
cached
)
free_base
=
!!
cache_add
(
&
p
->
bases
,
obj
,
elem
->
base_key
);
free_base
=
!!
cache_add
(
&
cached
,
&
p
->
bases
,
obj
,
elem
->
base_key
);
elem
=
&
stack
[
elem_pos
-
1
];
elem
=
&
stack
[
elem_pos
-
1
];
curpos
=
elem
->
offset
;
curpos
=
elem
->
offset
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment