diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2010-10-05 15:13:05 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2010-10-05 15:13:05 +0000 |
commit | fc5bd9d7faf53f805e2835a5f27fde0304445dcd (patch) | |
tree | e6cd29a75b765c7181973eb9af55011a0f6f4dec | |
parent | 2b1df88d67e31d4ca21af85d7de5585fcaf8bb30 (diff) |
rcs_state_check must check for more invalid characters than just space.
ok nicm
-rw-r--r-- | usr.bin/rcs/rcs.c | 20 | ||||
-rw-r--r-- | usr.bin/rcs/rcs.h | 3 |
2 files changed, 19 insertions, 4 deletions
diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c index 5b24cae112b..1d78ca83d1b 100644 --- a/usr.bin/rcs/rcs.c +++ b/usr.bin/rcs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.65 2010/09/29 09:23:54 tobias Exp $ */ +/* $OpenBSD: rcs.c,v 1.66 2010/10/05 15:13:04 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -98,6 +98,9 @@ struct rcs_pdata { #define RCS_TOKSTR(rfp) ((struct rcs_pdata *)rfp->rf_pdata)->rp_buf #define RCS_TOKLEN(rfp) ((struct rcs_pdata *)rfp->rf_pdata)->rp_tlen +/* invalid characters in RCS states */ +static const char rcs_state_invch[] = RCS_STATE_INVALCHAR; + /* invalid characters in RCS symbol names */ static const char rcs_sym_invch[] = RCS_SYM_INVALCHAR; @@ -2972,10 +2975,21 @@ rcs_state_set(RCSFILE *rfp, RCSNUM *rev, const char *state) int rcs_state_check(const char *state) { - if (strchr(state, ' ') != NULL) + int ret; + const char *cp; + + ret = 0; + cp = state; + if (!isalpha(*cp++)) return (-1); - return (0); + for (; *cp != '\0'; cp++) + if (!isgraph(*cp) || (strchr(rcs_state_invch, *cp) != NULL)) { + ret = -1; + break; + } + + return (ret); } /* diff --git a/usr.bin/rcs/rcs.h b/usr.bin/rcs/rcs.h index 4bd1ffa3302..01f3b6ed0ba 100644 --- a/usr.bin/rcs/rcs.h +++ b/usr.bin/rcs/rcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.h,v 1.10 2010/08/31 20:42:45 tobias Exp $ */ +/* $OpenBSD: rcs.h,v 1.11 2010/10/05 15:13:04 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -43,6 +43,7 @@ #define RCS_HEAD_REV ((RCSNUM *)(-1)) +#define RCS_STATE_INVALCHAR "$,:;@" #define RCS_SYM_INVALCHAR "$,.:;@" #define RCS_MAGIC_BRANCH ".0." |