summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-16 12:39:11 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-16 14:04:23 +0200
commit47a40d1d4421b0081622c1bf4af4f58ebb497ed5 (patch)
tree7505422a68e4b9f7dd0b455488b6d402c168c8ab /src
parentaeb2b991b0e645100976db620e50da65c51db66e (diff)
downloadlibgit2-cmn/url-empty.tar.gz
remote: return EINVALIDSPEC when given an empty URLcmn/url-empty
This is what we used to return in the settter and there's tests in bindings which ask for this. There's no particular reason to stop doing so.
Diffstat (limited to 'src')
-rw-r--r--src/remote.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/remote.c b/src/remote.c
index 63f6d3462..7c2d99937 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -167,14 +167,18 @@ static int get_check_cert(int *out, git_repository *repo)
static int canonicalize_url(git_buf *out, const char *in)
{
-#ifdef GIT_WIN32
- const char *c;
+ if (in == NULL || strlen(in) == 0) {
+ giterr_set(GITERR_INVALID, "cannot set empty URL");
+ return GIT_EINVALIDSPEC;
+ }
+#ifdef GIT_WIN32
/* Given a UNC path like \\server\path, we need to convert this
* to //server/path for compatibility with core git.
*/
if (in[0] == '\\' && in[1] == '\\' &&
(git__isalpha(in[2]) || git__isdigit(in[2]))) {
+ const char *c;
for (c = in; *c; c++)
git_buf_putc(out, *c == '\\' ? '/' : *c);