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
15d54fdd
Commit
15d54fdd
authored
Feb 10, 2015
by
Edward Thomson
Committed by
Edward Thomson
Feb 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odb__hashlink: check st.st_size before casting
parent
392702ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
src/odb.c
+9
-9
No files found.
src/odb.c
View file @
15d54fdd
...
...
@@ -216,28 +216,28 @@ int git_odb__hashfd_filtered(
int
git_odb__hashlink
(
git_oid
*
out
,
const
char
*
path
)
{
struct
stat
st
;
git_off
_t
size
;
size
_t
size
;
int
result
;
if
(
git_path_lstat
(
path
,
&
st
)
<
0
)
return
-
1
;
size
=
st
.
st_size
;
if
(
!
git__is_sizet
(
size
))
{
giterr_set
(
GITERR_OS
,
"File size overflow for 32-bit systems"
);
if
(
!
git__is_sizet
(
st
.
st_size
))
{
giterr_set
(
GITERR_FILESYSTEM
,
"File size overflow for 32-bit systems"
);
return
-
1
;
}
size
=
(
size_t
)
st
.
st_size
;
if
(
S_ISLNK
(
st
.
st_mode
))
{
char
*
link_data
;
ssize_t
read_len
;
GITERR_CHECK_ALLOC_ADD
(
size
,
1
);
link_data
=
git__malloc
(
(
size_t
)(
size
+
1
)
);
link_data
=
git__malloc
(
size
+
1
);
GITERR_CHECK_ALLOC
(
link_data
);
read_len
=
p_readlink
(
path
,
link_data
,
(
size_t
)
size
);
read_len
=
p_readlink
(
path
,
link_data
,
size
);
link_data
[
size
]
=
'\0'
;
if
(
read_len
!=
(
ssize_t
)
size
)
{
giterr_set
(
GITERR_OS
,
"Failed to read symlink data for '%s'"
,
path
);
...
...
@@ -245,13 +245,13 @@ int git_odb__hashlink(git_oid *out, const char *path)
return
-
1
;
}
result
=
git_odb_hash
(
out
,
link_data
,
(
size_t
)
size
,
GIT_OBJ_BLOB
);
result
=
git_odb_hash
(
out
,
link_data
,
size
,
GIT_OBJ_BLOB
);
git__free
(
link_data
);
}
else
{
int
fd
=
git_futils_open_ro
(
path
);
if
(
fd
<
0
)
return
-
1
;
result
=
git_odb__hashfd
(
out
,
fd
,
(
size_t
)
size
,
GIT_OBJ_BLOB
);
result
=
git_odb__hashfd
(
out
,
fd
,
size
,
GIT_OBJ_BLOB
);
p_close
(
fd
);
}
...
...
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