summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src/root.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cvs/src/root.c')
-rw-r--r--contrib/cvs/src/root.c69
1 files changed, 48 insertions, 21 deletions
diff --git a/contrib/cvs/src/root.c b/contrib/cvs/src/root.c
index d88c6f4..81859c8 100644
--- a/contrib/cvs/src/root.c
+++ b/contrib/cvs/src/root.c
@@ -174,9 +174,9 @@ Create_Root (dir, rootdir)
directories. Then we can check against them when a remote user
hands us a CVSROOT directory. */
-static unsigned int root_allow_count;
+static int root_allow_count;
static char **root_allow_vector;
-static unsigned int root_allow_size;
+static int root_allow_size;
void
root_allow_add (arg)
@@ -233,8 +233,7 @@ void
root_allow_free ()
{
if (root_allow_vector != NULL)
- free (root_allow_vector);
- root_allow_count = 0;
+ free_names (&root_allow_count, root_allow_vector);
root_allow_size = 0;
}
@@ -242,7 +241,7 @@ int
root_allow_ok (arg)
char *arg;
{
- unsigned int i;
+ int i;
if (root_allow_count == 0)
{
@@ -295,7 +294,7 @@ parse_cvsroot (CVSroot)
char *CVSroot;
{
static int cvsroot_parsed = 0;
- char *cvsroot_copy, *p;
+ char *cvsroot_copy, *cvsroot_save, *p;
int check_hostname;
/* Don't go through the trouble twice. */
@@ -305,10 +304,19 @@ parse_cvsroot (CVSroot)
return 0;
}
+ if (CVSroot_original != NULL)
+ free (CVSroot_original);
+ if (CVSroot_directory != NULL)
+ free (CVSroot_directory);
+ if (CVSroot_username != NULL)
+ free (CVSroot_username);
+ if (CVSroot_hostname != NULL)
+ free (CVSroot_hostname);
+
CVSroot_original = xstrdup (CVSroot);
- cvsroot_copy = xstrdup (CVSroot);
+ cvsroot_save = cvsroot_copy = xstrdup (CVSroot);
- if ((*cvsroot_copy == ':'))
+ if (*cvsroot_copy == ':')
{
char *method = ++cvsroot_copy;
@@ -324,6 +332,7 @@ parse_cvsroot (CVSroot)
if (! (p = strchr (method, ':')))
{
error (0, 0, "bad CVSroot: %s", CVSroot);
+ free (cvsroot_save);
return 1;
}
*p = '\0';
@@ -348,6 +357,7 @@ parse_cvsroot (CVSroot)
else
{
error (0, 0, "unknown method in CVSroot: %s", CVSroot);
+ free (cvsroot_save);
return 1;
}
}
@@ -378,19 +388,19 @@ parse_cvsroot (CVSroot)
{
/* Check to see if there is a username in the string. */
- if ((p = strchr (cvsroot_copy, '@')))
+ if ((p = strchr (cvsroot_copy, '@')) != NULL)
{
- CVSroot_username = cvsroot_copy;
*p = '\0';
+ CVSroot_username = xstrdup (cvsroot_copy);
cvsroot_copy = ++p;
if (*CVSroot_username == '\0')
CVSroot_username = NULL;
}
- if ((p = strchr (cvsroot_copy, ':')))
+ if ((p = strchr (cvsroot_copy, ':')) != NULL)
{
- CVSroot_hostname = cvsroot_copy;
*p = '\0';
+ CVSroot_hostname = xstrdup (cvsroot_copy);
cvsroot_copy = ++p;
if (*CVSroot_hostname == '\0')
@@ -398,7 +408,8 @@ parse_cvsroot (CVSroot)
}
}
- CVSroot_directory = cvsroot_copy;
+ CVSroot_directory = xstrdup(cvsroot_copy);
+ free (cvsroot_save);
#if ! defined (CLIENT_SUPPORT) && ! defined (DEBUG)
if (CVSroot_method != local_method)
@@ -422,12 +433,10 @@ parse_cvsroot (CVSroot)
switch (CVSroot_method)
{
case local_method:
- case fork_method:
if (CVSroot_username || CVSroot_hostname)
{
error (0, 0, "can't specify hostname and username in CVSROOT");
- error (0, 0, "when using %s access method",
- CVSroot_method == local_method ? "local" : "fork");
+ error (0, 0, "when using local access method");
error (0, 0, "(%s)", CVSroot);
return 1;
}
@@ -440,6 +449,18 @@ parse_cvsroot (CVSroot)
error (1, 0, "CVSROOT %s must be an absolute pathname",
CVSroot_directory);
break;
+ case fork_method:
+ /* We want :fork: to behave the same as other remote access
+ methods. Therefore, don't check to see that the repository
+ name is absolute -- let the server do it. */
+ if (CVSroot_username || CVSroot_hostname)
+ {
+ error (0, 0, "can't specify hostname and username in CVSROOT");
+ error (0, 0, "when using fork access method");
+ error (0, 0, "(%s)", CVSroot);
+ return 1;
+ }
+ break;
case kserver_method:
#ifndef HAVE_KERBEROS
error (0, 0, "Your CVSROOT is set for a kerberos access method");
@@ -488,18 +509,24 @@ parse_cvsroot (CVSroot)
/* Set up the global CVSroot* variables as if we're using the local
- repository DIR. DIR must point to storage which will last for the
- rest of the CVS invocation (for example, the caller might malloc it
- and never free it, or free it just before exiting CVS). */
+ repository DIR. */
void
set_local_cvsroot (dir)
char *dir;
{
- CVSroot_original = dir;
+ if (CVSroot_original != NULL)
+ free (CVSroot_original);
+ CVSroot_original = xstrdup(dir);
CVSroot_method = local_method;
- CVSroot_directory = CVSroot_original;
+ if (CVSroot_directory != NULL)
+ free (CVSroot_directory);
+ CVSroot_directory = xstrdup(dir);
+ if (CVSroot_username != NULL)
+ free (CVSroot_username);
CVSroot_username = NULL;
+ if (CVSroot_hostname != NULL)
+ free (CVSroot_hostname);
CVSroot_hostname = NULL;
client_active = 0;
}
OpenPOWER on IntegriCloud