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
cf83809b
Unverified
Commit
cf83809b
authored
Nov 13, 2018
by
Patrick Steinhardt
Committed by
GitHub
Nov 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4883 from pks-t/pks/signature-tz-oob
signature: fix out-of-bounds read when parsing timezone offset
parents
20cb30b6
52f859fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
src/signature.c
+1
-1
tests/commit/signature.c
+20
-0
No files found.
src/signature.c
View file @
cf83809b
...
...
@@ -248,7 +248,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
if
((
tz_start
[
0
]
!=
'-'
&&
tz_start
[
0
]
!=
'+'
)
||
git__strntol32
(
&
offset
,
tz_start
+
1
,
buffer_end
-
tz_start
+
1
,
&
tz_end
,
10
)
<
0
)
{
buffer_end
-
tz_start
-
1
,
&
tz_end
,
10
)
<
0
)
{
/* malformed timezone, just assume it's zero */
offset
=
0
;
}
...
...
tests/commit/signature.c
View file @
cf83809b
...
...
@@ -43,6 +43,26 @@ void test_commit_signature__leading_and_trailing_crud_is_trimmed(void)
assert_name_and_email
(
"nulltoken
\xe2\x98\xba
"
,
"emeric.fermas@gmail.com"
,
"nulltoken
\xe2\x98\xba
"
,
"emeric.fermas@gmail.com"
);
}
void
test_commit_signature__timezone_does_not_read_oob
(
void
)
{
const
char
*
header
=
"A <a@example.com> 1461698487 +1234"
,
*
header_end
;
git_signature
*
sig
;
/* Let the buffer end midway between the timezone offeset's "+12" and "34" */
header_end
=
header
+
strlen
(
header
)
-
2
;
sig
=
git__calloc
(
1
,
sizeof
(
git_signature
));
cl_assert
(
sig
);
cl_git_pass
(
git_signature__parse
(
sig
,
&
header
,
header_end
,
NULL
,
'\0'
));
cl_assert_equal_s
(
sig
->
name
,
"A"
);
cl_assert_equal_s
(
sig
->
email
,
"a@example.com"
);
cl_assert_equal_i
(
sig
->
when
.
time
,
1461698487
);
cl_assert_equal_i
(
sig
->
when
.
offset
,
12
);
git_signature_free
(
sig
);
}
void
test_commit_signature__angle_brackets_in_names_are_not_supported
(
void
)
{
cl_git_fail
(
try_build_signature
(
"<Phil Haack"
,
"phil@haack"
,
1234567890
,
60
));
...
...
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