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
62251409
Commit
62251409
authored
Nov 01, 2021
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs_path: add length with suffix validation
parent
91246ee5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
3 deletions
+30
-3
src/fs_path.c
+23
-0
src/fs_path.h
+4
-0
src/refdb_fs.c
+1
-1
src/repository.c
+2
-2
No files found.
src/fs_path.c
View file @
62251409
...
...
@@ -1715,6 +1715,29 @@ bool git_fs_path_str_is_valid_ext(
return
true
;
}
int
git_fs_path_validate_str_length_with_suffix
(
git_str
*
path
,
size_t
suffix_len
)
{
#ifdef GIT_WIN32
size_t
utf8_len
=
git_utf8_char_length
(
path
->
ptr
,
path
->
size
);
size_t
total_len
;
if
(
GIT_ADD_SIZET_OVERFLOW
(
&
total_len
,
utf8_len
,
suffix_len
)
||
total_len
>
MAX_PATH
)
{
git_error_set
(
GIT_ERROR_FILESYSTEM
,
"path too long: '%.*s'"
,
(
int
)
path
->
size
,
path
->
ptr
);
return
-
1
;
}
#else
GIT_UNUSED
(
path
);
GIT_UNUSED
(
suffix_len
);
#endif
return
0
;
}
#ifdef GIT_WIN32
GIT_INLINE
(
bool
)
should_validate_longpaths
(
git_repository
*
repo
)
{
...
...
src/fs_path.h
View file @
62251409
...
...
@@ -677,6 +677,10 @@ GIT_INLINE(bool) git_fs_path_str_is_valid(
return
git_fs_path_str_is_valid_ext
(
path
,
flags
,
NULL
,
NULL
,
NULL
,
NULL
);
}
extern
int
git_fs_path_validate_str_length_with_suffix
(
git_str
*
path
,
size_t
suffix_len
);
/**
* Validate an on-disk path, taking into account that it will have a
* suffix appended (eg, `.lock`).
...
...
src/refdb_fs.c
View file @
62251409
...
...
@@ -77,7 +77,7 @@ GIT_INLINE(int) loose_path(
if
(
git_str_joinpath
(
out
,
base
,
refname
)
<
0
)
return
-
1
;
return
git_fs_path_validate_
filesystem_with_suffix
(
out
->
ptr
,
out
->
size
,
return
git_fs_path_validate_
str_length_with_suffix
(
out
,
CONST_STRLEN
(
".lock"
));
}
...
...
src/repository.c
View file @
62251409
...
...
@@ -240,8 +240,8 @@ GIT_INLINE(int) validate_repo_path(git_str *path)
CONST_STRLEN
(
"objects/pack/pack-.pack.lock"
)
+
GIT_OID_HEXSZ
;
return
git_fs_path_validate_
filesystem
_with_suffix
(
path
->
ptr
,
path
->
size
,
suffix_len
);
return
git_fs_path_validate_
str_length
_with_suffix
(
path
,
suffix_len
);
}
/*
...
...
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