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
18e37db9
Commit
18e37db9
authored
May 16, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1591 from arrbee/reorder-reuc-read-for-safety
Ensure reuc vector is always valid
parents
4a782c82
57908bb3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/index.c
+8
-6
No files found.
src/index.c
View file @
18e37db9
...
@@ -1283,8 +1283,9 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
...
@@ -1283,8 +1283,9 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
size_t
len
;
size_t
len
;
int
i
;
int
i
;
/* This gets called multiple times, the vector might already be initialized */
/* If called multiple times, the vector might already be initialized */
if
(
index
->
reuc
.
_alloc_size
==
0
&&
git_vector_init
(
&
index
->
reuc
,
16
,
reuc_cmp
)
<
0
)
if
(
index
->
reuc
.
_alloc_size
==
0
&&
git_vector_init
(
&
index
->
reuc
,
16
,
reuc_cmp
)
<
0
)
return
-
1
;
return
-
1
;
while
(
size
)
{
while
(
size
)
{
...
@@ -1294,12 +1295,9 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
...
@@ -1294,12 +1295,9 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
if
(
size
<=
len
)
if
(
size
<=
len
)
return
index_error_invalid
(
"reading reuc entries"
);
return
index_error_invalid
(
"reading reuc entries"
);
lost
=
git__
malloc
(
sizeof
(
git_index_reuc_entry
));
lost
=
git__
calloc
(
1
,
sizeof
(
git_index_reuc_entry
));
GITERR_CHECK_ALLOC
(
lost
);
GITERR_CHECK_ALLOC
(
lost
);
if
(
git_vector_insert
(
&
index
->
reuc
,
lost
)
<
0
)
return
-
1
;
/* read NUL-terminated pathname for entry */
/* read NUL-terminated pathname for entry */
lost
->
path
=
git__strdup
(
buffer
);
lost
->
path
=
git__strdup
(
buffer
);
GITERR_CHECK_ALLOC
(
lost
->
path
);
GITERR_CHECK_ALLOC
(
lost
->
path
);
...
@@ -1337,6 +1335,10 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
...
@@ -1337,6 +1335,10 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
size
-=
20
;
size
-=
20
;
buffer
+=
20
;
buffer
+=
20
;
}
}
/* entry was read successfully - insert into reuc vector */
if
(
git_vector_insert
(
&
index
->
reuc
,
lost
)
<
0
)
return
-
1
;
}
}
/* entries are guaranteed to be sorted on-disk */
/* entries are guaranteed to be sorted on-disk */
...
...
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