summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/update.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-06-14 04:34:09 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-06-14 04:34:09 +0000
commit5267e13e6a0385ddc7c3db92e270bfc435bb4315 (patch)
treebd55b1a2655cc43467d17b0f982a8456c90ca222 /usr.bin/cvs/update.c
parent7d54e7807fd98844ba963369bffbc1a25397f82b (diff)
Conforming to RCS specification, it is possible but unlikely to encounter
an RCS file which has no head revision set. Some commands actually can work with them (log, status) so support these files. Fixes A LOT of possible segmentation faults. ok joris
Diffstat (limited to 'usr.bin/cvs/update.c')
-rw-r--r--usr.bin/cvs/update.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index ac7792d48d6..e4ef04e14b9 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.153 2008/06/14 03:58:29 tobias Exp $ */
+/* $OpenBSD: update.c,v 1.154 2008/06/14 04:34:08 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -351,24 +351,29 @@ cvs_update_local(struct cvs_file *cf)
else
cf->file_status = FILE_CHECKOUT;
- cf->file_rcsrev = rcs_head_get(cf->file_rcs);
+ if ((cf->file_rcsrev = rcs_head_get(cf->file_rcs)) == NULL)
+ fatal("no head revision in RCS file for %s",
+ cf->file_path);
/* might be a bit overkill */
if (cvs_server_active == 1)
cvs_server_clear_sticky(cf->file_wd);
}
- if (print_stdout && cf->file_status != FILE_UNKNOWN &&
- !cf->file_rcs->rf_dead) {
- rcsnum_tostr(cf->file_rcsrev, rbuf, sizeof(rbuf));
- if (verbosity > 1) {
- cvs_log(LP_RCS, RCS_DIFF_DIV);
- cvs_log(LP_RCS, "Checking out %s", cf->file_path);
- cvs_log(LP_RCS, "RCS: %s", cf->file_rpath);
- cvs_log(LP_RCS, "VERS: %s", rbuf);
- cvs_log(LP_RCS, "***************");
+ if (print_stdout) {
+ if (cf->file_status != FILE_UNKNOWN && cf->file_rcs != NULL &&
+ cf->file_rcsrev != NULL && !cf->file_rcs->rf_dead) {
+ rcsnum_tostr(cf->file_rcsrev, rbuf, sizeof(rbuf));
+ if (verbosity > 1) {
+ cvs_log(LP_RCS, RCS_DIFF_DIV);
+ cvs_log(LP_RCS, "Checking out %s",
+ cf->file_path);
+ cvs_log(LP_RCS, "RCS: %s", cf->file_rpath);
+ cvs_log(LP_RCS, "VERS: %s", rbuf);
+ cvs_log(LP_RCS, "***************");
+ }
+ cvs_checkout_file(cf, cf->file_rcsrev, tag, CO_DUMP);
}
- cvs_checkout_file(cf, cf->file_rcsrev, tag, CO_DUMP);
return;
}
@@ -376,7 +381,7 @@ cvs_update_local(struct cvs_file *cf)
if (cf->file_ent->ce_opts == NULL) {
if (kflag)
cf->file_status = FILE_CHECKOUT;
- } else {
+ } else if (cf->file_rcs != NULL) {
if (strlen(cf->file_ent->ce_opts) < 3)
fatal("malformed option for file %s",
cf->file_path);
@@ -631,6 +636,12 @@ update_join_file(struct cvs_file *cf)
goto out;
}
+ if (cf->file_rcsrev == NULL) {
+ cvs_printf("non-mergable file: %s has no head revision!\n",
+ cf->file_path);
+ goto out;
+ }
+
if (rev1 == NULL || !strcmp(state1, RCS_STATE_DEAD)) {
if (cf->fd != -1) {
cvs_printf("%s exists but has been added in %s\n",