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
a5e85d86
Commit
a5e85d86
authored
Nov 05, 2012
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1046 from libgit2/empty-remote-url-crash
Bail out of remote loading if the URL would be NULL
parents
065be7a1
c1cd036e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
src/remote.c
+6
-0
tests-clar/network/remotes.c
+10
-2
tests-clar/resources/testrepo.git/config
+2
-0
No files found.
src/remote.c
View file @
a5e85d86
...
...
@@ -131,6 +131,12 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
if
((
error
=
git_config_get_string
(
&
val
,
config
,
git_buf_cstr
(
&
buf
)))
<
0
)
goto
cleanup
;
if
(
!
val
)
{
giterr_set
(
GITERR_INVALID
,
"Malformed remote '%s' - missing URL"
,
name
);
error
=
-
1
;
goto
cleanup
;
}
remote
->
repo
=
repo
;
remote
->
url
=
git__strdup
(
val
);
...
...
tests-clar/network/remotes.c
View file @
a5e85d86
...
...
@@ -183,13 +183,13 @@ void test_network_remotes__list(void)
git_config
*
cfg
;
cl_git_pass
(
git_remote_list
(
&
list
,
_repo
));
cl_assert
(
list
.
count
==
3
);
cl_assert
(
list
.
count
==
4
);
git_strarray_free
(
&
list
);
cl_git_pass
(
git_repository_config
(
&
cfg
,
_repo
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"remote.specless.url"
,
"http://example.com"
));
cl_git_pass
(
git_remote_list
(
&
list
,
_repo
));
cl_assert
(
list
.
count
==
4
);
cl_assert
(
list
.
count
==
5
);
git_strarray_free
(
&
list
);
git_config_free
(
cfg
);
...
...
@@ -269,3 +269,11 @@ void test_network_remotes__tagopt(void)
git_config_free
(
cfg
);
}
void
test_network_remotes__cannot_load_with_an_empty_url
(
void
)
{
git_remote
*
remote
;
cl_git_fail
(
git_remote_load
(
&
remote
,
_repo
,
"empty-remote-url"
));
cl_assert
(
giterr_last
()
->
klass
==
GITERR_INVALID
);
}
tests-clar/resources/testrepo.git/config
View file @
a5e85d86
...
...
@@ -8,6 +8,8 @@
fetch = +refs/heads/*:refs/remotes/test/*
[remote "joshaber"]
url = git://github.com/libgit2/libgit2
[remote "empty-remote-url"]
url =
[remote "test_with_pushurl"]
url = git://github.com/libgit2/fetchlibgit2
...
...
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