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
471fa05e
Commit
471fa05e
authored
Jun 11, 2012
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix fragile commit parsing in revwalk
parent
0284a219
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
src/revwalk.c
+21
-15
No files found.
src/revwalk.c
View file @
471fa05e
...
@@ -169,14 +169,23 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
...
@@ -169,14 +169,23 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
return
commit
;
return
commit
;
}
}
static
int
commit_error
(
commit_object
*
commit
,
const
char
*
msg
)
{
char
commit_oid
[
GIT_OID_HEXSZ
+
1
];
git_oid_fmt
(
commit_oid
,
&
commit
->
oid
);
commit_oid
[
GIT_OID_HEXSZ
]
=
'\0'
;
giterr_set
(
GITERR_ODB
,
"Failed to parse commit %s - %s"
,
commit_oid
,
msg
);
return
-
1
;
}
static
int
commit_quick_parse
(
git_revwalk
*
walk
,
commit_object
*
commit
,
git_rawobj
*
raw
)
static
int
commit_quick_parse
(
git_revwalk
*
walk
,
commit_object
*
commit
,
git_rawobj
*
raw
)
{
{
const
size_t
parent_len
=
strlen
(
"parent "
)
+
GIT_OID_HEXSZ
+
1
;
const
size_t
parent_len
=
strlen
(
"parent "
)
+
GIT_OID_HEXSZ
+
1
;
unsigned
char
*
buffer
=
raw
->
data
;
unsigned
char
*
buffer
=
raw
->
data
;
unsigned
char
*
buffer_end
=
buffer
+
raw
->
len
;
unsigned
char
*
buffer_end
=
buffer
+
raw
->
len
;
unsigned
char
*
parents_start
;
unsigned
char
*
parents_start
;
int
i
,
parents
=
0
;
int
i
,
parents
=
0
;
int
commit_time
;
int
commit_time
;
...
@@ -207,21 +216,18 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
...
@@ -207,21 +216,18 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
commit
->
out_degree
=
(
unsigned
short
)
parents
;
commit
->
out_degree
=
(
unsigned
short
)
parents
;
if
((
buffer
=
memchr
(
buffer
,
'\n'
,
buffer_end
-
buffer
))
==
NULL
)
{
if
((
buffer
=
memchr
(
buffer
,
'\n'
,
buffer_end
-
buffer
))
==
NULL
)
giterr_set
(
GITERR_ODB
,
"Failed to parse commit. Object is corrupted"
);
return
commit_error
(
commit
,
"object is corrupted"
);
return
-
1
;
}
buffer
=
memchr
(
buffer
,
'>'
,
buffer_end
-
buffer
);
if
((
buffer
=
memchr
(
buffer
,
'<'
,
buffer_end
-
buffer
))
==
NULL
||
if
(
buffer
==
NULL
)
{
(
buffer
=
memchr
(
buffer
,
'>'
,
buffer_end
-
buffer
))
==
NULL
)
giterr_set
(
GITERR_ODB
,
"Failed to parse commit. Can't find author"
);
return
commit_error
(
commit
,
"malformed author information"
);
return
-
1
;
}
if
(
git__strtol32
(
&
commit_time
,
(
char
*
)
buffer
+
2
,
NULL
,
10
)
<
0
)
{
while
(
*
buffer
==
'>'
||
git__isspace
(
*
buffer
))
giterr_set
(
GITERR_ODB
,
"Failed to parse commit. Can't parse commit time"
);
buffer
++
;
return
-
1
;
}
if
(
git__strtol32
(
&
commit_time
,
(
char
*
)
buffer
,
NULL
,
10
)
<
0
)
return
commit_error
(
commit
,
"cannot parse commit time"
);
commit
->
time
=
(
time_t
)
commit_time
;
commit
->
time
=
(
time_t
)
commit_time
;
commit
->
parsed
=
1
;
commit
->
parsed
=
1
;
...
...
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