diff options
author | peter <peter@FreeBSD.org> | 2003-01-21 21:53:03 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-01-21 21:53:03 +0000 |
commit | 821118cc49e4fb917b543aff27dfeeb48f9959cb (patch) | |
tree | ac24d0bf3321edf74c485789b0a58c0ac84bb5fb /contrib/cvs/src | |
parent | 3dc96f7243ece1d1f7f87b03334f840415e0db63 (diff) | |
download | FreeBSD-src-821118cc49e4fb917b543aff27dfeeb48f9959cb.zip FreeBSD-src-821118cc49e4fb917b543aff27dfeeb48f9959cb.tar.gz |
Import cvs-1.11.5 onto vendor branch
Diffstat (limited to 'contrib/cvs/src')
28 files changed, 223 insertions, 137 deletions
diff --git a/contrib/cvs/src/ChangeLog b/contrib/cvs/src/ChangeLog index ed1188b..656ca2f 100644 --- a/contrib/cvs/src/ChangeLog +++ b/contrib/cvs/src/ChangeLog @@ -1,3 +1,92 @@ +2003-01-15 Karl Fogel <kfogel@collab.net> + + * server.c (dirswitch): Don't free dir_name until right before + allocating it again. This removes a potential double-free + problem, whereby this function could free dir_name and then + immediately return due to invalid directory syntax (without ever + reassigning dir_name), then reenter and free dir_name again. + + Thanks to Stefan Esser <s.esser@e-matters.de> for the fix. + +2003-01-08 Larry Jones <lawrence.jones@eds.com> + + * client.c (update_entries): Only "0" is a special version number; + other numbers starting with 0 (like 0.1) are normal version numbers. + * commit.c (find_fileproc): Ditto. Also reorganize the code to + simplify the conditions. + (Reported by Michele Zamparelli <michele.zamparelli@eso.org>.) + +2003-01-02 Larry Jones <lawrence.jones@eds.com> + + * rcs.c (getdelta): Use RCSDEAD rather than literal "dead". + +2002-12-27 Derek Price <derek@ximbiot.com> + + * admin.c: s/LOCK_(NONE|WRITE|READ)/CVS_$&/g; since the definition of + LOCK_WRITE clashes with a definition in objidl.h on Windoze platforms. + * annotate.c: Ditto. + * client.c: Ditto. + * commit.c: Ditto. + * cvs.h: Ditto. + * diff.c: Ditto. + * edit.c: Ditto. + * lock.c: Ditto. + * log.c: Ditto. + * patch.c: Ditto. + * recurse.c: Ditto. + * remove.c: Ditto. + * status.c: Ditto. + * tag.c: Ditto. + * update.c: Ditto. + * watch.c: Ditto. + * myndbm.c: Ditto & define O_ACCMODE when it isn't defined, as under + Windoze. + (Thanks to Stephane Rouleau <s.rouleau@videotron.ca>, + Cristopher Seawood <cls@seawood.org>, and + Frederico Costa <frederico.costa@tiscali.no> for all their hints, + tips, and patches for this problem.) + +2002-12-20 Derek Price <derek@ximbiot.com> + + * client.c (send_a_repository): Suppress a warning under Windoze. + +2002-12-19 Derek Price <derek@ximbiot.com> + + * Makefile.am: Remove reference to options.h. + * cvs.h: Ditto. + * options.h: Remove this obsolete file. + * sanity.sh: Remove comment about external diffs causing tests to fail + since CVS hasn't used external diffs in years. + + * Makefile.in: Regenerated. + +2002-12-16 Derek Price <derek@ximbiot.com> + + * admin.c: Disable cvsadmin group checking on the client. + (Reported by Dan Peterson <dbpete@aol.com>.) + +2002-12-06 Derek Price <derek@ximbiot.com> + + * buffer.c: Replace calls to malloc with calls to xmalloc and calls to + realloc with calls to xrealloc. + * parseinfo.c: Ditto. + * root.c: Ditto. + * server.c: Ditto. + * zlib.c: Ditto. + * scramble.c: Change some comments to refer to xmalloc rather than + malloc. + (Reported by Dan Peterson <dbpete@aol.com>.) + +2002-12-04 Derek Price <derek@ximbiot.com> + + * options.h: Remove CVS_ADMIN_GROUP. + +2002-12-02 Larry Jones <lawrence.jones@eds.com> + + * commit.c (commit): Strip leading zeros from numeric revision + in addition to trailing dots. + (Reported by Peter Meszaros <pme@prolan.hu>.) + 2002-11-22 Larry Jones <lawrence.jones@eds.com> * sanity.sh: Note that the tests run for a long time. diff --git a/contrib/cvs/src/Makefile.am b/contrib/cvs/src/Makefile.am index 3338eec..0195f56 100644 --- a/contrib/cvs/src/Makefile.am +++ b/contrib/cvs/src/Makefile.am @@ -89,7 +89,6 @@ cvs_SOURCES = \ hardlink.h \ hash.h \ myndbm.h \ - options.h \ rcs.h \ root.h \ server.h \ diff --git a/contrib/cvs/src/Makefile.in b/contrib/cvs/src/Makefile.in index 3a56e0c..189cd28 100644 --- a/contrib/cvs/src/Makefile.in +++ b/contrib/cvs/src/Makefile.in @@ -175,7 +175,6 @@ cvs_SOURCES = \ hardlink.h \ hash.h \ myndbm.h \ - options.h \ rcs.h \ root.h \ server.h \ diff --git a/contrib/cvs/src/admin.c b/contrib/cvs/src/admin.c index 8c4fce3..6a5649a 100644 --- a/contrib/cvs/src/admin.c +++ b/contrib/cvs/src/admin.c @@ -377,9 +377,19 @@ admin (argc, argv) #ifdef CVS_ADMIN_GROUP /* The use of `cvs admin -k' is unrestricted. However, any other - option is restricted if the group CVS_ADMIN_GROUP exists. */ - if (!only_k_option && - (grp = getgrnam(CVS_ADMIN_GROUP)) != NULL) + option is restricted if the group CVS_ADMIN_GROUP exists on the + server. */ + if ( +# ifdef CLIENT_SUPPORT + /* This is only "secure" on the server, since the user could edit the + * RCS file on a local host, but some people like this kind of + * check anyhow. The alternative would be to check only when + * (server_active) rather than when not on the client. + */ + !current_parsed_root->isremote && +# endif /* CLIENT_SUPPORT */ + !only_k_option + && (grp = getgrnam(CVS_ADMIN_GROUP)) != NULL) { #ifdef HAVE_GETGROUPS gid_t *grps; @@ -411,7 +421,7 @@ admin (argc, argv) CVS_ADMIN_GROUP); #endif } -#endif +#endif /* defined CVS_ADMIN_GROUP */ for (i = 0; i < admin_data.ac; ++i) { @@ -510,7 +520,7 @@ admin (argc, argv) err = start_recursion (admin_fileproc, (FILESDONEPROC) NULL, admin_dirproc, (DIRLEAVEPROC) NULL, (void *)&admin_data, argc, argv, 0, - W_LOCAL, 0, LOCK_NONE, (char *) NULL, 1); + W_LOCAL, 0, CVS_LOCK_NONE, (char *) NULL, 1); Lock_Cleanup (); return_it: diff --git a/contrib/cvs/src/annotate.c b/contrib/cvs/src/annotate.c index 8c72962..2e3cb89 100644 --- a/contrib/cvs/src/annotate.c +++ b/contrib/cvs/src/annotate.c @@ -248,7 +248,7 @@ rannotate_proc (argc, argv, xwhere, mwhere, mfile, shorten, local, mname, msg) err = start_recursion (annotate_fileproc, (FILESDONEPROC) NULL, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, - argc - 1, argv + 1, local, which, 0, LOCK_READ, + argc - 1, argv + 1, local, which, 0, CVS_LOCK_READ, where, 1); return err; } diff --git a/contrib/cvs/src/buffer.c b/contrib/cvs/src/buffer.c index ba98b4f..fd98d82 100644 --- a/contrib/cvs/src/buffer.c +++ b/contrib/cvs/src/buffer.c @@ -106,7 +106,7 @@ allocate_buffer_datas () #define ALLOC_COUNT (16) alc = ((struct buffer_data *) - malloc (ALLOC_COUNT * sizeof (struct buffer_data))); + xmalloc (ALLOC_COUNT * sizeof (struct buffer_data))); space = (char *) valloc (ALLOC_COUNT * BUFFER_DATA_SIZE); if (alc == NULL || space == NULL) return; @@ -154,7 +154,7 @@ buf_empty_p (buf) #ifdef SERVER_FLOWCONTROL /* * Count how much data is stored in the buffer.. - * Note that each buffer is a malloc'ed chunk BUFFER_DATA_SIZE. + * Note that each buffer is a xmalloc'ed chunk BUFFER_DATA_SIZE. */ int @@ -794,7 +794,7 @@ buf_read_line (buf, line, lenp) char *p; struct buffer_data *nldata; - p = malloc (len + 1); + p = xmalloc (len + 1); if (p == NULL) return -2; *line = p; @@ -1233,7 +1233,7 @@ stdio_buffer_initialize (fp, child_pid, input, memory) int input; void (*memory) PROTO((struct buffer *)); { - struct stdio_buffer_closure *bc = malloc (sizeof (*bc)); + struct stdio_buffer_closure *bc = xmalloc (sizeof (*bc)); bc->fp = fp; bc->child_pid = child_pid; @@ -1677,7 +1677,7 @@ packetizing_buffer_input (closure, data, need, size, got) /* We didn't allocate enough space in the initialize function. */ - n = realloc (pb->holdbuf, count + 2); + n = xrealloc (pb->holdbuf, count + 2); if (n == NULL) { (*pb->buf->memory_error) (pb->buf); @@ -1739,7 +1739,7 @@ packetizing_buffer_input (closure, data, need, size, got) outbuf = stackoutbuf; else { - outbuf = malloc (count); + outbuf = xmalloc (count); if (outbuf == NULL) { (*pb->buf->memory_error) (pb->buf); @@ -1811,7 +1811,7 @@ packetizing_buffer_output (closure, data, have, wrote) if (have > BUFFER_DATA_SIZE) { - /* It would be easy to malloc a buffer, but I don't think this + /* It would be easy to xmalloc a buffer, but I don't think this case can ever arise. */ abort (); } diff --git a/contrib/cvs/src/client.c b/contrib/cvs/src/client.c index a5a15e14..94e902a 100644 --- a/contrib/cvs/src/client.c +++ b/contrib/cvs/src/client.c @@ -2175,7 +2175,7 @@ update_entries (data_arg, ent_list, short_pathname, filename) * date. Create a dummy timestamp which will never compare * equal to the timestamp of the file. */ - if (vn[0] == '\0' || vn[0] == '0' || vn[0] == '-') + if (vn[0] == '\0' || strcmp (vn, "0") == 0 || vn[0] == '-') local_timestamp = "dummy timestamp"; else if (local_timestamp == NULL) { @@ -3001,7 +3001,7 @@ send_a_repository (dir, repository, update_dir) && (strcmp (repository + repository_len - update_dir_len, update_dir) == 0) /* TOPLEVEL_REPOS shouldn't be above current_parsed_root->directory */ - && ((repository_len - update_dir_len) + && ((size_t)(repository_len - update_dir_len) > strlen (current_parsed_root->directory))) { /* The repository name contains UPDATE_DIR. Set @@ -5631,7 +5631,7 @@ send_files (argc, argv, local, aflag, flags) err = start_recursion (send_fileproc, send_filesdoneproc, send_dirent_proc, send_dirleave_proc, (void *) &args, - argc, argv, local, W_LOCAL, aflag, LOCK_NONE, (char *)NULL, 0); + argc, argv, local, W_LOCAL, aflag, CVS_LOCK_NONE, (char *)NULL, 0); if (err) error_exit (); if (toplevel_repos == NULL) diff --git a/contrib/cvs/src/commit.c b/contrib/cvs/src/commit.c index d67d0a1..0d19d31 100644 --- a/contrib/cvs/src/commit.c +++ b/contrib/cvs/src/commit.c @@ -248,26 +248,7 @@ find_fileproc (callerdat, finfo) xfinfo.rcs = NULL; vers = Version_TS (&xfinfo, NULL, saved_tag, NULL, 0, 0); - if (vers->ts_user == NULL - && vers->vn_user != NULL - && (vers->vn_user[0] == '0' || vers->vn_user[0] == '-')) - { - if ( vers->vn_user[0] == '0') - { - /* This happens when one has `cvs add'ed a file, but it no - longer exists in the working directory at commit time. */ - status = T_ADDED; - } - else - { - /* FIXME: If vn_user is starts with "-" but ts_user is - non-NULL, what classify_file does is print "%s should be - removed and is still there". I'm not sure what it does - then. We probably should do the same. */ - status = T_REMOVED; - } - } - else if (vers->vn_user == NULL) + if (vers->vn_user == NULL) { if (vers->ts_user == NULL) error (0, 0, "nothing known about `%s'", finfo->fullname); @@ -277,16 +258,28 @@ find_fileproc (callerdat, finfo) freevers_ts (&vers); return 1; } - else if (vers->ts_user != NULL - && vers->vn_user != NULL - && vers->vn_user[0] == '0') - /* FIXME: If vn_user is "0" but ts_user is NULL, what classify_file - does is print "new-born %s has disappeared" and removes the entry. - We probably should do the same. No! Not here. Otherwise, a commit - would succeed in some cases when it should fail. See above. */ + if (vers->ts_user == NULL) + { + if (strcmp (vers->vn_user, "0") == 0) + /* This happens when one has `cvs add'ed a file, but it no + longer exists in the working directory at commit time. + FIXME: What classify_file does in this case is print + "new-born %s has disappeared" and removes the entry. + We probably should do the same. */ + status = T_ADDED; + else if (vers->vn_user[0] == '-') + status = T_REMOVED; + else + { + /* FIXME: What classify_file does in this case is print + "%s was lost". We probably should do the same. */ + freevers_ts (&vers); + return 0; + } + } + else if (strcmp (vers->vn_user, "0") == 0) status = T_ADDED; - else if (vers->ts_user != NULL - && vers->ts_rcs != NULL + else if (vers->ts_rcs != NULL && (args->force || strcmp (vers->ts_user, vers->ts_rcs) != 0)) /* If we are forcing commits, pretend that the file is modified. */ @@ -427,10 +420,12 @@ commit (argc, argv) /* numeric specified revision means we ignore sticky tags... */ if (saved_tag && isdigit ((unsigned char) *saved_tag)) { + char *p = saved_tag + strlen (saved_tag); aflag = 1; - /* strip trailing dots */ - while (saved_tag[strlen (saved_tag) - 1] == '.') - saved_tag[strlen (saved_tag) - 1] = '\0'; + /* strip trailing dots and leading zeros */ + while (*--p == '.') ; + p[1] = '\0'; + while (*saved_tag == '0') ++saved_tag; } /* some checks related to the "-F logfile" option */ @@ -466,7 +461,7 @@ commit (argc, argv) err = start_recursion (find_fileproc, find_filesdoneproc, find_dirent_proc, (DIRLEAVEPROC) NULL, (void *)&find_args, - argc, argv, local, W_LOCAL, 0, LOCK_NONE, + argc, argv, local, W_LOCAL, 0, CVS_LOCK_NONE, (char *)NULL, 0); if (err) error (1, 0, "correct above errors first!"); @@ -647,7 +642,7 @@ commit (argc, argv) */ err = start_recursion (check_fileproc, check_filesdoneproc, check_direntproc, (DIRLEAVEPROC) NULL, NULL, argc, - argv, local, W_LOCAL, aflag, LOCK_NONE, + argv, local, W_LOCAL, aflag, CVS_LOCK_NONE, (char *) NULL, 1); if (err) { @@ -662,7 +657,7 @@ commit (argc, argv) if (noexec == 0) err = start_recursion (commit_fileproc, commit_filesdoneproc, commit_direntproc, commit_dirleaveproc, NULL, - argc, argv, local, W_LOCAL, aflag, LOCK_NONE, + argc, argv, local, W_LOCAL, aflag, CVS_LOCK_NONE, (char *) NULL, 1); /* diff --git a/contrib/cvs/src/cvs.h b/contrib/cvs/src/cvs.h index 799a3f3..9b8a8b4 100644 --- a/contrib/cvs/src/cvs.h +++ b/contrib/cvs/src/cvs.h @@ -15,9 +15,6 @@ #ifdef HAVE_CONFIG_H # include <config.h> /* this is stuff found via autoconf */ #endif /* CONFIG_H */ -#include "options.h" /* these are some larger questions which - can't easily be automatically checked - for */ /* Changed from if __STDC__ to ifdef __STDC__ because of Sun's acc compiler */ @@ -266,12 +263,10 @@ extern int errno; #define CVSREAD_DFLT 0 /* writable files by default */ #define TMPDIR_ENV "TMPDIR" /* Temporary directory */ -/* #define TMPDIR_DFLT Set by options.h */ #define EDITOR1_ENV "CVSEDITOR" /* which editor to use */ #define EDITOR2_ENV "VISUAL" /* which editor to use */ #define EDITOR3_ENV "EDITOR" /* which editor to use */ -/* #define EDITOR_DFLT Set by options.h */ #define CVSROOT_ENV "CVSROOT" /* source directory root */ #define CVSROOT_DFLT NULL /* No dflt; must set for checkout */ @@ -280,7 +275,6 @@ extern int errno; #define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */ #define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */ -/* #define CVSUMASK_DFLT Set by options.h */ /* * If the beginning of the Repository matches the following string, strip it @@ -365,9 +359,9 @@ typedef enum direnter_type Dtype; #endif /* Recursion processor lock types */ -#define LOCK_NONE 0 -#define LOCK_READ 1 -#define LOCK_WRITE 2 +#define CVS_LOCK_NONE 0 +#define CVS_LOCK_READ 1 +#define CVS_LOCK_WRITE 2 extern char *program_name, *program_path, *command_name; extern char *Tmpdir, *Editor; diff --git a/contrib/cvs/src/diff.c b/contrib/cvs/src/diff.c index 2efa1e3..88af651 100644 --- a/contrib/cvs/src/diff.c +++ b/contrib/cvs/src/diff.c @@ -422,7 +422,7 @@ diff (argc, argv) /* start the recursion processor */ err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc, diff_dirleaveproc, NULL, argc, argv, local, - which, 0, LOCK_READ, (char *) NULL, 1); + which, 0, CVS_LOCK_READ, (char *) NULL, 1); /* clean up */ free (options); diff --git a/contrib/cvs/src/edit.c b/contrib/cvs/src/edit.c index e0995e5..cde03f9 100644 --- a/contrib/cvs/src/edit.c +++ b/contrib/cvs/src/edit.c @@ -103,7 +103,7 @@ watch_onoff (argc, argv) err = start_recursion (onoff_fileproc, onoff_filesdoneproc, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, - argc, argv, local, W_LOCAL, 0, LOCK_NONE, + argc, argv, local, W_LOCAL, 0, CVS_LOCK_NONE, (char *)NULL, 0); Lock_Cleanup (); diff --git a/contrib/cvs/src/lock.c b/contrib/cvs/src/lock.c index 986e0cb..9333d9b 100644 --- a/contrib/cvs/src/lock.c +++ b/contrib/cvs/src/lock.c @@ -925,7 +925,7 @@ lock_tree_for_write (argc, argv, local, which, aflag) lock_tree_list = getlist (); err = start_recursion ((FILEPROC) NULL, lock_filesdoneproc, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, argc, - argv, local, which, aflag, LOCK_NONE, + argv, local, which, aflag, CVS_LOCK_NONE, (char *) NULL, 0); sortlist (lock_tree_list, fsortcmp); if (Writer_Lock (lock_tree_list) != 0) diff --git a/contrib/cvs/src/log.c b/contrib/cvs/src/log.c index c7e5600..ce9ba5c0 100644 --- a/contrib/cvs/src/log.c +++ b/contrib/cvs/src/log.c @@ -550,7 +550,7 @@ rlog_proc (argc, argv, xwhere, mwhere, mfile, shorten, local, mname, msg) err = start_recursion (log_fileproc, (FILESDONEPROC) NULL, log_dirproc, (DIRLEAVEPROC) NULL, (void *) &log_data, - argc - 1, argv + 1, local, which, 0, LOCK_READ, + argc - 1, argv + 1, local, which, 0, CVS_LOCK_READ, where, 1); return err; } diff --git a/contrib/cvs/src/myndbm.c b/contrib/cvs/src/myndbm.c index 69c0836..aa71ca8 100644 --- a/contrib/cvs/src/myndbm.c +++ b/contrib/cvs/src/myndbm.c @@ -18,6 +18,9 @@ #include "getline.h" #ifdef MY_NDBM +# ifndef O_ACCMODE +# define O_ACCMODE O_RDONLY|O_WRONLY|O_RDWR +# endif /* defined O_ACCMODE */ static void mydbm_load_file PROTO ((FILE *, List *, char *)); diff --git a/contrib/cvs/src/parseinfo.c b/contrib/cvs/src/parseinfo.c index e0eb3a5..9771692 100644 --- a/contrib/cvs/src/parseinfo.c +++ b/contrib/cvs/src/parseinfo.c @@ -234,7 +234,7 @@ parse_config (cvsroot) return 0; parsed = 1; - infopath = malloc (strlen (cvsroot) + infopath = xmalloc (strlen (cvsroot) + sizeof (CVSROOTADM_CONFIG) + sizeof (CVSROOTADM) + 10); @@ -385,7 +385,7 @@ warning: this CVS does not support PreservePermissions"); { if (strcmp (p, "all") != 0) { - logHistory=malloc(strlen (p) + 1); + logHistory=xmalloc(strlen (p) + 1); strcpy (logHistory, p); } } diff --git a/contrib/cvs/src/patch.c b/contrib/cvs/src/patch.c index 4a027a1..e6a25f5 100644 --- a/contrib/cvs/src/patch.c +++ b/contrib/cvs/src/patch.c @@ -356,7 +356,7 @@ patch_proc (argc, argv, xwhere, mwhere, mfile, shorten, local_specified, err = start_recursion (patch_fileproc, (FILESDONEPROC) NULL, patch_dirproc, (DIRLEAVEPROC) NULL, NULL, argc - 1, argv + 1, local_specified, - which, 0, LOCK_READ, where, 1); + which, 0, CVS_LOCK_READ, where, 1); free (where); return (err); diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c index 7105540..2b2725d 100644 --- a/contrib/cvs/src/rcs.c +++ b/contrib/cvs/src/rcs.c @@ -7533,7 +7533,7 @@ unable to parse %s; `author' not in the expected place", rcsfile); unable to parse %s; `state' not in the expected place", rcsfile); vnode->state = rcsbuf_valcopy (rcsbuf, value, 0, (size_t *) NULL); /* The value is optional, according to rcsfile(5). */ - if (value != NULL && STREQ (value, "dead")) + if (value != NULL && STREQ (value, RCSDEAD)) { vnode->dead = 1; } @@ -7619,7 +7619,7 @@ unable to parse %s; `state' not in the expected place", rcsfile); vnode->dead = 1; if (vnode->state != NULL) free (vnode->state); - vnode->state = xstrdup ("dead"); + vnode->state = xstrdup (RCSDEAD); continue; } /* if we have a new revision number, we're done with this delta */ diff --git a/contrib/cvs/src/recurse.c b/contrib/cvs/src/recurse.c index e7cb861..d5eeabf 100644 --- a/contrib/cvs/src/recurse.c +++ b/contrib/cvs/src/recurse.c @@ -511,7 +511,7 @@ do_recursion (frame) if (frame->flags == R_SKIP_ALL) return (0); - locktype = noexec ? LOCK_NONE : frame->locktype; + locktype = noexec ? CVS_LOCK_NONE : frame->locktype; /* The fact that locks are not active here is what makes us fail to have the @@ -551,7 +551,7 @@ do_recursion (frame) * generating data, to give the buffers a chance to drain to the * remote client. We should not have locks active at this point, * but if there are writelocks around, we cannot pause here. */ - if (server_active && locktype != LOCK_NONE) + if (server_active && locktype != CVS_LOCK_NONE) server_pause_check(); #endif @@ -706,12 +706,12 @@ do_recursion (frame) /* read lock it if necessary */ if (repository) { - if (locktype == LOCK_READ) + if (locktype == CVS_LOCK_READ) { if (Reader_Lock (repository) != 0) error (1, 0, "read lock failed - giving up"); } - else if (locktype == LOCK_WRITE) + else if (locktype == CVS_LOCK_WRITE) lock_dir_for_write (repository); } @@ -736,7 +736,7 @@ do_recursion (frame) err += walklist (filelist, do_file_proc, &frfile); /* unlock it */ - if (locktype != LOCK_NONE) + if (locktype != CVS_LOCK_NONE) Lock_Cleanup (); /* clean up */ diff --git a/contrib/cvs/src/remove.c b/contrib/cvs/src/remove.c index c9224bd..01cdfb4 100644 --- a/contrib/cvs/src/remove.c +++ b/contrib/cvs/src/remove.c @@ -90,7 +90,7 @@ cvsremove (argc, argv) start_recursion (remove_force_fileproc, (FILESDONEPROC) NULL, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, (void *) NULL, argc, argv, local, W_LOCAL, - 0, LOCK_NONE, (char *) NULL, 0); + 0, CVS_LOCK_NONE, (char *) NULL, 0); } /* else FIXME should probably act as if the file doesn't exist in doing the following checks. */ @@ -114,7 +114,7 @@ cvsremove (argc, argv) err = start_recursion (remove_fileproc, (FILESDONEPROC) NULL, remove_dirproc, (DIRLEAVEPROC) NULL, NULL, argc, argv, - local, W_LOCAL, 0, LOCK_READ, (char *) NULL, 1); + local, W_LOCAL, 0, CVS_LOCK_READ, (char *) NULL, 1); if (removed_files && !really_quiet) error (0, 0, "use '%s commit' to remove %s permanently", program_name, diff --git a/contrib/cvs/src/root.c b/contrib/cvs/src/root.c index 9bbbe47..8308e97 100644 --- a/contrib/cvs/src/root.c +++ b/contrib/cvs/src/root.c @@ -191,13 +191,13 @@ root_allow_add (arg) { root_allow_size = 1; root_allow_vector = - (char **) malloc (root_allow_size * sizeof (char *)); + (char **) xmalloc (root_allow_size * sizeof (char *)); } else { root_allow_size *= 2; root_allow_vector = - (char **) realloc (root_allow_vector, + (char **) xrealloc (root_allow_vector, root_allow_size * sizeof (char *)); } @@ -212,7 +212,7 @@ error ENOMEM Virtual memory exhausted.\n"); error_exit (); } } - p = malloc (strlen (arg) + 1); + p = xmalloc (strlen (arg) + 1); if (p == NULL) goto no_memory; strcpy (p, arg); diff --git a/contrib/cvs/src/sanity.sh b/contrib/cvs/src/sanity.sh index 935b78c..c6e504e 100755 --- a/contrib/cvs/src/sanity.sh +++ b/contrib/cvs/src/sanity.sh @@ -4336,9 +4336,6 @@ ${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently" dotest_fail death2-diff-1 "${testcvs} -q diff file1" \ "${PROG} [a-z]*: file1 was removed, no comparison available" - # If the DIFF that CVS is using (options.h) is Sun diff, this - # test is said to fail (I think the /dev/null is the part - # that differs), along with a number of the other similar tests. dotest_fail death2-diff-2 "${testcvs} -q diff -N -c file1" \ "Index: file1 =================================================================== diff --git a/contrib/cvs/src/scramble.c b/contrib/cvs/src/scramble.c index 77376fa..487cbf4 100644 --- a/contrib/cvs/src/scramble.c +++ b/contrib/cvs/src/scramble.c @@ -75,14 +75,14 @@ shifts[] = { * single letter indicating the scrambling method. As of this * writing, the only legal method is 'A', but check the code for more * up-to-date information. The copy will have been allocated with - * malloc(). + * xmalloc(). * - * descramble(SCRM) returns STR, again in its own malloc'd space. + * descramble(SCRM) returns STR, again in its own xmalloc'd space. * descramble() uses SCRM[0] to determine which method of unscrambling * to use. If it does not recognize the method, it dies with error. */ -/* Return a malloc'd, scrambled version of STR. */ +/* Return a xmalloc'd, scrambled version of STR. */ char * scramble (str) char *str; diff --git a/contrib/cvs/src/server.c b/contrib/cvs/src/server.c index 9a0c132..04d912c 100644 --- a/contrib/cvs/src/server.c +++ b/contrib/cvs/src/server.c @@ -349,17 +349,17 @@ create_adm_p (base_dir, dir) return 0; /* nothing to do */ /* Allocate some space for our directory-munging string. */ - p = malloc (strlen (dir) + 1); + p = xmalloc (strlen (dir) + 1); if (p == NULL) return ENOMEM; - dir_where_cvsadm_lives = malloc (strlen (base_dir) + strlen (dir) + 100); + dir_where_cvsadm_lives = xmalloc (strlen (base_dir) + strlen (dir) + 100); if (dir_where_cvsadm_lives == NULL) return ENOMEM; /* Allocate some space for the temporary string in which we will construct filenames. */ - tmp = malloc (strlen (base_dir) + strlen (dir) + 100); + tmp = xmalloc (strlen (base_dir) + strlen (dir) + 100); if (tmp == NULL) return ENOMEM; @@ -399,7 +399,7 @@ create_adm_p (base_dir, dir) differently. */ char *empty; - empty = malloc (strlen (current_parsed_root->directory) + empty = xmalloc (strlen (current_parsed_root->directory) + sizeof (CVSROOTADM) + sizeof (CVSNULLREPOS) + 3); @@ -517,7 +517,7 @@ mkdir_p (dir) char *dir; { char *p; - char *q = malloc (strlen (dir) + 1); + char *q = xmalloc (strlen (dir) + 1); int retval; if (q == NULL) @@ -644,7 +644,7 @@ alloc_pending (size) this case. But we might as well handle it if they don't, I guess. */ return 0; - pending_error_text = malloc (size); + pending_error_text = xmalloc (size); if (pending_error_text == NULL) { pending_error = ENOMEM; @@ -772,7 +772,7 @@ E Protocol error: Root says \"%s\" but pserver says \"%s\"", nothing. But for rsh, we need to do it now. */ parse_config (current_parsed_root->directory); - path = malloc (strlen (current_parsed_root->directory) + path = xmalloc (strlen (current_parsed_root->directory) + sizeof (CVSROOTADM) + 2); if (path == NULL) @@ -791,7 +791,7 @@ E Protocol error: Root says \"%s\" but pserver says \"%s\"", free (path); #ifdef HAVE_PUTENV - env = malloc (strlen (CVSROOT_ENV) + strlen (current_parsed_root->directory) + 2); + env = xmalloc (strlen (CVSROOT_ENV) + strlen (current_parsed_root->directory) + 2); if (env == NULL) { pending_error = ENOMEM; @@ -922,7 +922,7 @@ serve_max_dotdot (arg) if (lim < 0) return; - p = malloc (strlen (server_temp_dir) + 2 * lim + 10); + p = xmalloc (strlen (server_temp_dir) + 2 * lim + 10); if (p == NULL) { pending_error = ENOMEM; @@ -971,9 +971,6 @@ dirswitch (dir, repos) return; } - if (dir_name != NULL) - free (dir_name); - dir_len = strlen (dir); /* Check for a trailing '/'. This is not ISDIRSEP because \ in the @@ -989,7 +986,10 @@ dirswitch (dir, repos) return; } - dir_name = malloc (strlen (server_temp_dir) + dir_len + 40); + if (dir_name != NULL) + free (dir_name); + + dir_name = xmalloc (strlen (server_temp_dir) + dir_len + 40); if (dir_name == NULL) { pending_error = ENOMEM; @@ -1161,7 +1161,7 @@ serve_directory (arg) } else { - pending_error_text = malloc (80 + strlen (arg)); + pending_error_text = xmalloc (80 + strlen (arg)); if (pending_error_text == NULL) { pending_error = ENOMEM; @@ -1268,7 +1268,7 @@ receive_partial_file (size, file) pending_error = ENOMEM; else { - pending_error_text = malloc (80); + pending_error_text = xmalloc (80); if (pending_error_text == NULL) pending_error = ENOMEM; else if (status == -1) @@ -1355,7 +1355,7 @@ receive_file (size, file, gzipped) char *filebuf; char *p; - filebuf = malloc (size); + filebuf = xmalloc (size); p = filebuf; /* If NULL, we still want to read the data and discard it. */ @@ -1371,7 +1371,7 @@ receive_file (size, file, gzipped) pending_error = ENOMEM; else { - pending_error_text = malloc (80); + pending_error_text = xmalloc (80); if (pending_error_text == NULL) pending_error = ENOMEM; else if (status == -1) @@ -1417,7 +1417,7 @@ receive_file (size, file, gzipped) if (pending_error_text) { - char *p = realloc (pending_error_text, + char *p = xrealloc (pending_error_text, strlen (pending_error_text) + strlen (arg) + 30); if (p) { @@ -1474,7 +1474,7 @@ serve_modified (arg) pending_error = ENOMEM; else { - pending_error_text = malloc (80 + strlen (arg)); + pending_error_text = xmalloc (80 + strlen (arg)); if (pending_error_text == NULL) pending_error = ENOMEM; else @@ -1500,7 +1500,7 @@ serve_modified (arg) pending_error = ENOMEM; else { - pending_error_text = malloc (80 + strlen (arg)); + pending_error_text = xmalloc (80 + strlen (arg)); if (pending_error_text == NULL) pending_error = ENOMEM; else @@ -1714,13 +1714,13 @@ serve_is_modified (arg) { /* We got Is-modified but no Entry. Add a dummy entry. The "D" timestamp is what makes it a dummy. */ - p = (struct an_entry *) malloc (sizeof (struct an_entry)); + p = (struct an_entry *) xmalloc (sizeof (struct an_entry)); if (p == NULL) { pending_error = ENOMEM; return; } - p->entry = malloc (strlen (arg) + 80); + p->entry = xmalloc (strlen (arg) + 80); if (p->entry == NULL) { pending_error = ENOMEM; @@ -1751,14 +1751,14 @@ serve_entry (arg) struct an_entry *p; char *cp; if (error_pending()) return; - p = (struct an_entry *) malloc (sizeof (struct an_entry)); + p = (struct an_entry *) xmalloc (sizeof (struct an_entry)); if (p == NULL) { pending_error = ENOMEM; return; } /* Leave space for serve_unchanged to write '=' if it wants. */ - cp = malloc (strlen (arg) + 2); + cp = xmalloc (strlen (arg) + 2); if (cp == NULL) { pending_error = ENOMEM; @@ -1800,7 +1800,7 @@ serve_kopt (arg) return; } - kopt = malloc (strlen (arg) + 1); + kopt = xmalloc (strlen (arg) + 1); if (kopt == NULL) { pending_error = ENOMEM; @@ -1894,13 +1894,13 @@ server_write_entries () } struct notify_note { - /* Directory in which this notification happens. malloc'd*/ + /* Directory in which this notification happens. xmalloc'd*/ char *dir; - /* malloc'd. */ + /* xmalloc'd. */ char *filename; - /* The following three all in one malloc'd block, pointed to by TYPE. + /* The following three all in one xmalloc'd block, pointed to by TYPE. Each '\0' terminated. */ /* "E" or "U". */ char *type; @@ -1933,14 +1933,14 @@ serve_notify (arg) if (dir_name == NULL) goto error; - new = (struct notify_note *) malloc (sizeof (struct notify_note)); + new = (struct notify_note *) xmalloc (sizeof (struct notify_note)); if (new == NULL) { pending_error = ENOMEM; return; } - new->dir = malloc (strlen (dir_name) + 1); - new->filename = malloc (strlen (arg) + 1); + new->dir = xmalloc (strlen (dir_name) + 1); + new->filename = xmalloc (strlen (arg) + 1); if (new->dir == NULL || new->filename == NULL) { pending_error = ENOMEM; @@ -1959,7 +1959,7 @@ serve_notify (arg) pending_error = ENOMEM; else { - pending_error_text = malloc (80 + strlen (arg)); + pending_error_text = xmalloc (80 + strlen (arg)); if (pending_error_text == NULL) pending_error = ENOMEM; else @@ -2119,7 +2119,7 @@ serve_argument (arg) { argument_vector_size *= 2; argument_vector = - (char **) realloc ((char *)argument_vector, + (char **) xrealloc ((char *)argument_vector, argument_vector_size * sizeof (char *)); if (argument_vector == NULL) { @@ -2127,7 +2127,7 @@ serve_argument (arg) return; } } - p = malloc (strlen (arg) + 1); + p = xmalloc (strlen (arg) + 1); if (p == NULL) { pending_error = ENOMEM; @@ -2146,7 +2146,7 @@ serve_argumentx (arg) if (error_pending()) return; p = argument_vector[argument_count - 1]; - p = realloc (p, strlen (p) + 1 + strlen (arg) + 1); + p = xrealloc (p, strlen (p) + 1 + strlen (arg) + 1); if (p == NULL) { pending_error = ENOMEM; @@ -3857,7 +3857,7 @@ serve_co (arg) * The client has not sent a "Repository" line. Check out * into a pristine directory. */ - tempdir = malloc (strlen (server_temp_dir) + 80); + tempdir = xmalloc (strlen (server_temp_dir) + 80); if (tempdir == NULL) { buf_output0 (buf_to_net, "E Out of memory\n"); @@ -5060,7 +5060,7 @@ server (argc, argv) int status; int i = 0; - server_temp_dir = malloc (strlen (Tmpdir) + 80); + server_temp_dir = xmalloc (strlen (Tmpdir) + 80); if (server_temp_dir == NULL) { /* diff --git a/contrib/cvs/src/status.c b/contrib/cvs/src/status.c index 6057ec2..b7853e5 100644 --- a/contrib/cvs/src/status.c +++ b/contrib/cvs/src/status.c @@ -107,7 +107,7 @@ cvsstatus (argc, argv) err = start_recursion (status_fileproc, (FILESDONEPROC) NULL, status_dirproc, (DIRLEAVEPROC) NULL, NULL, argc, argv, local, - W_LOCAL, 0, LOCK_READ, (char *) NULL, 1); + W_LOCAL, 0, CVS_LOCK_READ, (char *) NULL, 1); return (err); } diff --git a/contrib/cvs/src/tag.c b/contrib/cvs/src/tag.c index 467ba9d..73c241e 100644 --- a/contrib/cvs/src/tag.c +++ b/contrib/cvs/src/tag.c @@ -382,7 +382,7 @@ rtag_proc (argc, argv, xwhere, mwhere, mfile, shorten, local_specified, err = start_recursion (check_fileproc, check_filesdoneproc, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, argc - 1, argv + 1, local_specified, which, 0, - LOCK_READ, where, 1); + CVS_LOCK_READ, where, 1); if (err) { @@ -397,7 +397,7 @@ rtag_proc (argc, argv, xwhere, mwhere, mfile, shorten, local_specified, err = start_recursion (is_rtag ? rtag_fileproc : tag_fileproc, (FILESDONEPROC) NULL, tag_dirproc, (DIRLEAVEPROC) NULL, NULL, argc - 1, argv + 1, - local_specified, which, 0, LOCK_WRITE, where, 1); + local_specified, which, 0, CVS_LOCK_WRITE, where, 1); dellist (&mtlist); if (where != NULL) free (where); @@ -1285,7 +1285,7 @@ Numeric tag %s contains characters other than digits and '.'", name); val_direntproc, (DIRLEAVEPROC) NULL, (void *)&the_val_args, argc, argv, local, which, aflag, - LOCK_READ, NULL, 1); + CVS_LOCK_READ, NULL, 1); if (repository != NULL && repository[0] != '\0') { if (restore_cwd (&cwd, NULL)) diff --git a/contrib/cvs/src/update.c b/contrib/cvs/src/update.c index af9a2bd..b7c21eb 100644 --- a/contrib/cvs/src/update.c +++ b/contrib/cvs/src/update.c @@ -492,7 +492,7 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag, follows it; someone should make sure that I did it right. */ err = start_recursion (get_linkinfo_proc, (FILESDONEPROC) NULL, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, - argc, argv, local, which, aflag, LOCK_READ, + argc, argv, local, which, aflag, CVS_LOCK_READ, preload_update_dir, 1); if (err) return (err); @@ -508,7 +508,7 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag, /* call the recursion processor */ err = start_recursion (update_fileproc, update_filesdone_proc, update_dirent_proc, update_dirleave_proc, NULL, - argc, argv, local, which, aflag, LOCK_READ, + argc, argv, local, which, aflag, CVS_LOCK_READ, preload_update_dir, 1); #ifdef SERVER_SUPPORT diff --git a/contrib/cvs/src/watch.c b/contrib/cvs/src/watch.c index 96d6b04..8c57ebe 100644 --- a/contrib/cvs/src/watch.c +++ b/contrib/cvs/src/watch.c @@ -341,7 +341,7 @@ watch_addremove (argc, argv) err = start_recursion (addremove_fileproc, addremove_filesdoneproc, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, - argc, argv, local, W_LOCAL, 0, LOCK_NONE, + argc, argv, local, W_LOCAL, 0, CVS_LOCK_NONE, (char *)NULL, 1); Lock_Cleanup (); @@ -515,6 +515,6 @@ watchers (argc, argv) return start_recursion (watchers_fileproc, (FILESDONEPROC) NULL, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, - argc, argv, local, W_LOCAL, 0, LOCK_READ, + argc, argv, local, W_LOCAL, 0, CVS_LOCK_READ, (char *)NULL, 1); } diff --git a/contrib/cvs/src/zlib.c b/contrib/cvs/src/zlib.c index 1fc7a72..00b3682 100644 --- a/contrib/cvs/src/zlib.c +++ b/contrib/cvs/src/zlib.c @@ -153,10 +153,10 @@ compress_buffer_input (closure, data, need, size, got) bd = cb->buf->data; if (bd == NULL) { - bd = ((struct buffer_data *) malloc (sizeof (struct buffer_data))); + bd = ((struct buffer_data *) xmalloc (sizeof (struct buffer_data))); if (bd == NULL) return -2; - bd->text = (char *) malloc (BUFFER_DATA_SIZE); + bd->text = (char *) xmalloc (BUFFER_DATA_SIZE); if (bd->text == NULL) { free (bd); @@ -535,7 +535,7 @@ gunzip_and_write (fd, fullname, buf, size) } /* Read all of FD and put the gzipped data (RFC1952/RFC1951) into *BUF, - replacing previous contents of *BUF. *BUF is malloc'd and *SIZE is + replacing previous contents of *BUF. *BUF is xmalloc'd and *SIZE is its allocated size. Put the actual number of bytes of data in *LEN. If something goes wrong, give a nonfatal error mentioning FULLNAME as the name of the file for FD, and return 1 if we can't @@ -561,7 +561,7 @@ read_and_gzip (fd, fullname, buf, size, len, level) unsigned char *newbuf; *size = 1024; - newbuf = realloc (*buf, *size); + newbuf = xrealloc (*buf, *size); if (newbuf == NULL) { error (0, 0, "out of memory"); @@ -622,7 +622,7 @@ read_and_gzip (fd, fullname, buf, size, len, level) offset = zstr.next_out - *buf; *size *= 2; - newbuf = realloc (*buf, *size); + newbuf = xrealloc (*buf, *size); if (newbuf == NULL) { error (0, 0, "out of memory"); |