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
6b349ecc
Commit
6b349ecc
authored
5 years ago
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odb loose: only read at most INT_MAX
parent
8c925ef8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
src/odb_loose.c
+14
-7
No files found.
src/odb_loose.c
View file @
6b349ecc
...
...
@@ -408,7 +408,8 @@ done:
static
int
read_header_loose
(
git_rawobj
*
out
,
git_buf
*
loc
)
{
unsigned
char
obj
[
1024
];
int
fd
,
obj_len
,
error
;
ssize_t
obj_len
;
int
fd
,
error
;
assert
(
out
&&
loc
);
...
...
@@ -417,10 +418,14 @@ static int read_header_loose(git_rawobj *out, git_buf *loc)
out
->
data
=
NULL
;
if
((
error
=
fd
=
git_futils_open_ro
(
loc
->
ptr
))
<
0
||
(
error
=
obj_len
=
p_read
(
fd
,
obj
,
sizeof
(
obj
)))
<
0
)
if
((
error
=
fd
=
git_futils_open_ro
(
loc
->
ptr
))
<
0
)
goto
done
;
if
((
obj_len
=
p_read
(
fd
,
obj
,
sizeof
(
obj
)))
<
0
)
{
error
=
(
int
)
obj_len
;
goto
done
;
}
if
(
!
is_zlib_compressed_data
(
obj
,
(
size_t
)
obj_len
))
error
=
read_header_loose_packlike
(
out
,
obj
,
(
size_t
)
obj_len
);
else
...
...
@@ -871,6 +876,8 @@ static int loose_backend__readstream_read(
size_t
start_remain
=
stream
->
start_len
-
stream
->
start_read
;
int
total
=
0
,
error
;
buffer_len
=
min
(
buffer_len
,
INT_MAX
);
/*
* if we read more than just the header in the initial read, play
* that back for the caller.
...
...
@@ -882,20 +889,20 @@ static int loose_backend__readstream_read(
buffer
+=
chunk
;
stream
->
start_read
+=
chunk
;
total
+=
chunk
;
total
+=
(
int
)
chunk
;
buffer_len
-=
chunk
;
}
if
(
buffer_len
)
{
size_t
chunk
=
min
(
buffer_len
,
INT_MAX
)
;
size_t
chunk
=
buffer_len
;
if
((
error
=
git_zstream_get_output
(
buffer
,
&
chunk
,
&
stream
->
zstream
))
<
0
)
return
error
;
total
+=
chunk
;
total
+=
(
int
)
chunk
;
}
return
total
;
return
(
int
)
total
;
}
static
void
loose_backend__readstream_free
(
git_odb_stream
*
_stream
)
...
...
This diff is collapsed.
Click to expand it.
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