commit.c: make find_commit_subject() more robust
[gitweb.git] / connect.c
index 1f7b7694f66d11d2ac7cc45e03a9c69e96860b02..27a706f76621621a25b7e58188e5d1da9b9a2ccd 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -9,6 +9,7 @@
 #include "url.h"
 #include "string-list.h"
 #include "sha1-array.h"
+#include "transport.h"
 
 static char *server_capabilities;
 static const char *parse_feature_value(const char *, const char *, int *);
@@ -310,6 +311,8 @@ static void get_host_and_port(char **host, const char **port)
                if (end != colon + 1 && *end == '\0' && 0 <= portnr && portnr < 65536) {
                        *colon = 0;
                        *port = colon + 1;
+               } else if (!colon[1]) {
+                       *colon = 0;
                }
        }
 }
@@ -692,6 +695,8 @@ struct child_process *git_connect(int fd[2], const char *url,
                else
                        target_host = xstrdup(hostandport);
 
+               transport_check_allowed("git");
+
                /* These underlying connection commands die() if they
                 * cannot connect.
                 */
@@ -725,6 +730,7 @@ struct child_process *git_connect(int fd[2], const char *url,
                        int putty, tortoiseplink = 0;
                        char *ssh_host = hostandport;
                        const char *port = NULL;
+                       transport_check_allowed("ssh");
                        get_host_and_port(&ssh_host, &port);
 
                        if (!port)
@@ -739,6 +745,7 @@ struct child_process *git_connect(int fd[2], const char *url,
 
                                free(hostandport);
                                free(path);
+                               free(conn);
                                return NULL;
                        }
 
@@ -778,6 +785,7 @@ struct child_process *git_connect(int fd[2], const char *url,
                        /* remove repo-local variables from the environment */
                        conn->env = local_repo_env;
                        conn->use_shell = 1;
+                       transport_check_allowed("file");
                }
                argv_array_push(&conn->args, cmd.buf);