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
a25519ac
Commit
a25519ac
authored
Aug 09, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1770 from ethomson/index_fuzz
Fixes to safely reading the index
parents
d1be9e4c
a1f69452
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+16
-3
src/index.c
+4
-3
src/posix.h
+4
-0
src/util.h
+3
-0
src/win32/mingw-compat.h
+5
-0
No files found.
src/index.c
View file @
a25519ac
...
...
@@ -1371,7 +1371,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
while
(
size
)
{
git_index_reuc_entry
*
lost
;
len
=
strlen
(
buffer
)
+
1
;
len
=
p_strnlen
(
buffer
,
size
)
+
1
;
if
(
size
<=
len
)
return
index_error_invalid
(
"reading reuc entries"
);
...
...
@@ -1444,7 +1444,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
return
-
1
;
#define read_conflict_name(ptr) \
len =
strlen(buffer
) + 1; \
len =
p_strnlen(buffer, size
) + 1; \
if (size < len) \
return index_error_invalid("reading conflict name entries"); \
\
...
...
@@ -1571,7 +1571,8 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
total_size
=
dest
.
extension_size
+
sizeof
(
struct
index_extension
);
if
(
buffer_size
<
total_size
||
if
(
dest
.
extension_size
>
total_size
||
buffer_size
<
total_size
||
buffer_size
-
total_size
<
INDEX_FOOTER_SIZE
)
return
0
;
...
...
src/posix.h
View file @
a25519ac
...
...
@@ -93,6 +93,10 @@ extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
# include "unix/posix.h"
#endif
#ifndef __MINGW32__
# define p_strnlen strnlen
#endif
#ifdef NO_READDIR_R
# include <dirent.h>
GIT_INLINE
(
int
)
p_readdir_r
(
DIR
*
dirp
,
struct
dirent
*
entry
,
struct
dirent
**
result
)
...
...
src/util.h
View file @
a25519ac
...
...
@@ -55,6 +55,9 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
ptr
=
(
char
*
)
git__malloc
(
length
+
1
);
if
(
!
ptr
)
return
NULL
;
if
(
length
)
memcpy
(
ptr
,
str
,
length
);
...
...
src/win32/mingw-compat.h
View file @
a25519ac
...
...
@@ -19,6 +19,11 @@
# define S_IFLNK _S_IFLNK
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
GIT_INLINE
(
size_t
)
p_strnlen
(
const
char
*
s
,
size_t
maxlen
)
{
const
char
*
end
=
memchr
(
s
,
0
,
maxlen
);
return
end
?
(
end
-
s
)
:
maxlen
;
}
#endif
#endif
/* INCLUDE_mingw_compat__ */
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