mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 20:42:23 +00:00
Prevent another segfault from bad URL
This commit is contained in:
parent
887df99f17
commit
048f837b2f
@ -680,7 +680,7 @@ int gitno_extract_url_parts(
|
|||||||
at = strchr(url, '@');
|
at = strchr(url, '@');
|
||||||
|
|
||||||
if (!slash ||
|
if (!slash ||
|
||||||
(colon && slash < colon)) {
|
(colon && (slash < colon))) {
|
||||||
giterr_set(GITERR_NET, "Malformed URL");
|
giterr_set(GITERR_NET, "Malformed URL");
|
||||||
return GIT_EINVALIDSPEC;
|
return GIT_EINVALIDSPEC;
|
||||||
}
|
}
|
||||||
|
@ -213,10 +213,6 @@ static int git_ssh_extract_url_parts(
|
|||||||
|
|
||||||
colon = strchr(url, ':');
|
colon = strchr(url, ':');
|
||||||
|
|
||||||
if (colon == NULL) {
|
|
||||||
giterr_set(GITERR_NET, "Malformed URL: missing :");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
at = strchr(url, '@');
|
at = strchr(url, '@');
|
||||||
if (at) {
|
if (at) {
|
||||||
@ -228,6 +224,11 @@ static int git_ssh_extract_url_parts(
|
|||||||
*username = NULL;
|
*username = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (colon == NULL || (colon < start)) {
|
||||||
|
giterr_set(GITERR_NET, "Malformed URL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
*host = git__substrdup(start, colon - start);
|
*host = git__substrdup(start, colon - start);
|
||||||
GITERR_CHECK_ALLOC(*host);
|
GITERR_CHECK_ALLOC(*host);
|
||||||
|
|
||||||
@ -316,7 +317,7 @@ static int _git_ssh_setup_conn(
|
|||||||
const char *cmd,
|
const char *cmd,
|
||||||
git_smart_subtransport_stream **stream)
|
git_smart_subtransport_stream **stream)
|
||||||
{
|
{
|
||||||
char *host, *port=NULL, *user=NULL, *pass=NULL;
|
char *host=NULL, *port=NULL, *user=NULL, *pass=NULL;
|
||||||
const char *default_port="22";
|
const char *default_port="22";
|
||||||
ssh_stream *s;
|
ssh_stream *s;
|
||||||
LIBSSH2_SESSION* session=NULL;
|
LIBSSH2_SESSION* session=NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user