diff options
-rw-r--r-- | usr.bin/cvs/add.c | 8 | ||||
-rw-r--r-- | usr.bin/cvs/commit.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 8 | ||||
-rw-r--r-- | usr.bin/cvs/import.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/rcs.c | 53 | ||||
-rw-r--r-- | usr.bin/cvs/status.c | 13 |
6 files changed, 77 insertions, 15 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index 6a9a4c8e432..663883c54a1 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.82 2007/09/23 11:19:24 joris Exp $ */ +/* $OpenBSD: add.c,v 1.83 2008/01/10 09:37:26 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -257,6 +257,9 @@ add_file(struct cvs_file *cf) if (cf->file_rcs != NULL) { head = rcs_head_get(cf->file_rcs); + if (head == NULL) + fatal("RCS head empty or missing in %s\n", + cf->file_rcs->rf_path); rcsnum_tostr(head, revbuf, sizeof(revbuf)); rcsnum_free(head); } @@ -278,6 +281,9 @@ add_file(struct cvs_file *cf) /* Restore the file. */ head = rcs_head_get(cf->file_rcs); + if (head == NULL) + fatal("RCS head empty or missing in %s\n", + cf->file_rcs->rf_path); cvs_checkout_file(cf, head, NULL, 0); rcsnum_free(head); diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index 1a8bc470599..b388e5bdbb9 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.115 2007/10/08 14:13:13 joris Exp $ */ +/* $OpenBSD: commit.c,v 1.116 2008/01/10 09:37:26 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -299,6 +299,9 @@ cvs_commit_local(struct cvs_file *cf) && cf->file_rcs != NULL && cf->file_rcs->rf_dead == 1)) { rrev = rcs_head_get(cf->file_rcs); crev = rcs_head_get(cf->file_rcs); + if (crev == NULL || rrev == NULL) + fatal("RCS head empty or missing in %s\n", + cf->file_rcs->rf_path); tag = cvs_directory_tag; if (cf->file_ent != NULL && cf->file_ent->ce_tag != NULL) diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 9e6f27660b1..df2aa365ae5 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.205 2007/11/09 16:21:24 tobias Exp $ */ +/* $OpenBSD: file.c,v 1.206 2008/01/10 09:37:26 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -670,9 +670,11 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) cf->file_rcs)) != NULL) { rcsnum_tostr(cf->file_rcsrev, r1, sizeof(r1)); } else { - notag = 1; cf->file_rcsrev = rcs_head_get(cf->file_rcs); - cf->file_flags &= ~FILE_HAS_TAG; + if (cf->file_rcsrev != NULL) { + notag = 1; + cf->file_flags &= ~FILE_HAS_TAG; + } } } else if (cf->file_ent != NULL && cf->file_ent->ce_tag != NULL) { cf->file_rcsrev = rcsnum_alloc(); diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c index b0ee976a11a..59a636906be 100644 --- a/usr.bin/cvs/import.c +++ b/usr.bin/cvs/import.c @@ -1,4 +1,4 @@ -/* $OpenBSD: import.c,v 1.77 2007/09/22 16:01:22 joris Exp $ */ +/* $OpenBSD: import.c,v 1.78 2008/01/10 09:37:26 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -326,6 +326,9 @@ import_update(struct cvs_file *cf) newrev = rcsnum_inc(rev); } else { hrev = rcs_head_get(cf->file_rcs); + if (hrev == NULL) + fatal("RCS head empty or missing in %s\n", + cf->file_rcs->rf_path); d = import_get_rcsdiff(cf, hrev); rcsnum_free(hrev); newrev = rcsnum_brtorev(brev); diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 0fc30994ff9..37dd91ca340 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.233 2008/01/10 09:35:02 tobias Exp $ */ +/* $OpenBSD: rcs.c,v 1.234 2008/01/10 09:37:26 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -543,6 +543,9 @@ rcs_head_get(RCSFILE *file) struct rcs_delta *rdp; RCSNUM *rev, *rootrev; + if (file->rf_head == NULL) + return NULL; + rev = rcsnum_alloc(); if (file->rf_branch != NULL) { /* we have a default branch, use that to calculate the @@ -3297,10 +3300,30 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct cvs_lines *lines, size_t i; /* $Log: rcs.c,v $ + /* Revision 1.234 2008/01/10 09:37:26 tobias + /* RCS files without head keyword mustn't segfault our implementation. Only + /* command that supports such files is "cvs status", therefore properly handle + /* them in all other commands, too. + /* /* Revision 1.233 2008/01/10 09:35:02 tobias - /* Added support for keyword $Log$. In order to support $Log$, new lines have + /* Added support for keyword $Log: rcs.c,v $ + /* Added support for keyword Revision 1.234 2008/01/10 09:37:26 tobias + /* Added support for keyword RCS files without head keyword mustn't segfault our implementation. Only + /* Added support for keyword command that supports such files is "cvs status", therefore properly handle + /* Added support for keyword them in all other commands, too. + /* Added support for keyword. In order to support $Log: rcs.c,v $ + /* Added support for keyword $Log$. In order to support Revision 1.234 2008/01/10 09:37:26 tobias + /* Added support for keyword $Log$. In order to support RCS files without head keyword mustn't segfault our implementation. Only + /* Added support for keyword $Log$. In order to support command that supports such files is "cvs status", therefore properly handle + /* Added support for keyword $Log$. In order to support them in all other commands, too. + /* Added support for keyword $Log$. In order to support, new lines have /* to be added which mustn't be expanded again (this log message for example - /* would loop forever due to $Log$ keywords in it). + /* would loop forever due to $Log: rcs.c,v $ + /* would loop forever due to Revision 1.234 2008/01/10 09:37:26 tobias + /* would loop forever due to RCS files without head keyword mustn't segfault our implementation. Only + /* would loop forever due to command that supports such files is "cvs status", therefore properly handle + /* would loop forever due to them in all other commands, too. + /* would loop forever due to keywords in it). /* line */ if (!(kwtype & RCS_KW_FULLPATH)) (void)strlcat(expbuf, @@ -3386,10 +3409,30 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct cvs_lines *lines, /* * This is just another hairy mess, but it must * be done: All characters behind $Log: rcs.c,v $ + * be done: All characters behind Revision 1.234 2008/01/10 09:37:26 tobias + * be done: All characters behind RCS files without head keyword mustn't segfault our implementation. Only + * be done: All characters behind command that supports such files is "cvs status", therefore properly handle + * be done: All characters behind them in all other commands, too. + * be done: All characters behind * be done: All characters behind Revision 1.233 2008/01/10 09:35:02 tobias - * be done: All characters behind Added support for keyword $Log$. In order to support $Log$, new lines have + * be done: All characters behind Added support for keyword $Log: rcs.c,v $ + * be done: All characters behind Added support for keyword Revision 1.234 2008/01/10 09:37:26 tobias + * be done: All characters behind Added support for keyword RCS files without head keyword mustn't segfault our implementation. Only + * be done: All characters behind Added support for keyword command that supports such files is "cvs status", therefore properly handle + * be done: All characters behind Added support for keyword them in all other commands, too. + * be done: All characters behind Added support for keyword. In order to support $Log: rcs.c,v $ + * be done: All characters behind Added support for keyword $Log$. In order to support Revision 1.234 2008/01/10 09:37:26 tobias + * be done: All characters behind Added support for keyword $Log$. In order to support RCS files without head keyword mustn't segfault our implementation. Only + * be done: All characters behind Added support for keyword $Log$. In order to support command that supports such files is "cvs status", therefore properly handle + * be done: All characters behind Added support for keyword $Log$. In order to support them in all other commands, too. + * be done: All characters behind Added support for keyword $Log$. In order to support, new lines have * be done: All characters behind to be added which mustn't be expanded again (this log message for example - * be done: All characters behind would loop forever due to $Log$ keywords in it). + * be done: All characters behind would loop forever due to $Log: rcs.c,v $ + * be done: All characters behind would loop forever due to Revision 1.234 2008/01/10 09:37:26 tobias + * be done: All characters behind would loop forever due to RCS files without head keyword mustn't segfault our implementation. Only + * be done: All characters behind would loop forever due to command that supports such files is "cvs status", therefore properly handle + * be done: All characters behind would loop forever due to them in all other commands, too. + * be done: All characters behind would loop forever due to keywords in it). * be done: All characters behind will be * written in a new line next to log messages. * But that's not enough, we have to strip all diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c index 7a9efef391d..82faa18cdde 100644 --- a/usr.bin/cvs/status.c +++ b/usr.bin/cvs/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.77 2007/09/22 16:01:22 joris Exp $ */ +/* $OpenBSD: status.c,v 1.78 2008/01/10 09:37:26 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -132,6 +132,10 @@ cvs_status_local(struct cvs_file *cf) return; } + head = rcs_head_get(cf->file_rcs); + if (head == NULL && cf->file_status != FILE_REMOVE_ENTRY) + return; + cvs_printf("%s\n", CVS_STATUS_SEP); status = status_tab[cf->file_status]; @@ -141,6 +145,7 @@ cvs_status_local(struct cvs_file *cf) if (cf->file_status == FILE_LOST || cf->file_status == FILE_UNKNOWN || + cf->file_status == FILE_REMOVE_ENTRY || (cf->file_rcs != NULL && cf->in_attic == 1 && cf->fd == -1)) { (void)xsnprintf(buf, sizeof(buf), "no file %s\t", cf->file_name); @@ -153,7 +158,8 @@ cvs_status_local(struct cvs_file *cf) if (cf->file_ent == NULL) { (void)xsnprintf(buf, sizeof(buf), "No entry for %s", cf->file_name); - } else if (cf->file_status == FILE_ADDED) { + } else if (cf->file_status == FILE_ADDED || + cf->file_status == FILE_REMOVE_ENTRY) { len = strlcpy(buf, "New file!", sizeof(buf)); if (len >= sizeof(buf)) fatal("cvs_status_local: truncation"); @@ -181,12 +187,11 @@ cvs_status_local(struct cvs_file *cf) cvs_printf(" Working revision:\t%s\n", buf); buf[0] = '\0'; - if (cf->file_rcs == NULL) { + if (cf->file_rcs == NULL || head == NULL) { len = strlcat(buf, "No revision control file", sizeof(buf)); if (len >= sizeof(buf)) fatal("cvs_status_local: truncation"); } else { - head = rcs_head_get(cf->file_rcs); rcsnum_tostr(head, revbuf, sizeof(revbuf)); rcsnum_free(head); (void)xsnprintf(buf, sizeof(buf), "%s\t%s", revbuf, |