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
ee5da720
Commit
ee5da720
authored
Dec 02, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reference_create: validate loose names
Validate loose reference names on Win32.
parent
a64119e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
+46
-4
src/refdb_fs.c
+1
-1
tests/refs/create.c
+45
-3
No files found.
src/refdb_fs.c
View file @
ee5da720
...
...
@@ -707,7 +707,7 @@ static int reference_path_available(
static
int
loose_lock
(
git_filebuf
*
file
,
refdb_fs_backend
*
backend
,
const
char
*
name
)
{
int
error
;
int
error
;
git_buf
ref_path
=
GIT_BUF_INIT
;
assert
(
file
&&
backend
&&
name
);
...
...
tests/refs/create.c
View file @
ee5da720
...
...
@@ -151,13 +151,11 @@ void test_refs_create__propagate_eexists(void)
cl_assert
(
error
==
GIT_EEXISTS
);
}
void
test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALIDSPEC
(
void
)
static
void
test_invalid_name
(
const
char
*
name
)
{
git_reference
*
new_reference
;
git_oid
id
;
const
char
*
name
=
"refs/heads/inv@{id"
;
git_oid_fromstr
(
&
id
,
current_master_tip
);
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
git_reference_create
(
...
...
@@ -166,3 +164,47 @@ void test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALI
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
git_reference_symbolic_create
(
&
new_reference
,
g_repo
,
name
,
current_head_target
,
0
,
NULL
,
NULL
));
}
void
test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALIDSPEC
(
void
)
{
test_invalid_name
(
"refs/heads/inv@{id"
);
test_invalid_name
(
"refs/heads/back
\\
slash"
);
test_invalid_name
(
"refs/heads/foo "
);
test_invalid_name
(
"refs/heads/foo /bar"
);
test_invalid_name
(
"refs/heads/com1:bar/foo"
);
test_invalid_name
(
"refs/heads/e:"
);
test_invalid_name
(
"refs/heads/c:/foo"
);
test_invalid_name
(
"refs/heads/foo."
);
}
static
void
test_win32_name
(
const
char
*
name
)
{
git_reference
*
new_reference
=
NULL
;
git_oid
id
;
int
ret
;
git_oid_fromstr
(
&
id
,
current_master_tip
);
ret
=
git_reference_create
(
&
new_reference
,
g_repo
,
name
,
&
id
,
0
,
NULL
,
NULL
);
#ifdef GIT_WIN32
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
ret
);
#else
cl_git_pass
(
ret
);
#endif
git_reference_free
(
new_reference
);
}
void
test_refs_create__creating_a_loose_ref_with_invalid_windows_name
(
void
)
{
test_win32_name
(
"refs/heads/foo./bar"
);
test_win32_name
(
"refs/heads/aux"
);
test_win32_name
(
"refs/heads/aux.foo/bar"
);
test_win32_name
(
"refs/heads/com1"
);
}
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