diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2019-01-09 17:55:29 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2019-01-09 17:55:29 +0000 |
commit | 3b059c343d522391b4d6c78dac90e823797e1e5f (patch) | |
tree | e097d6729ec6109b25fa06d925d82b3b34e6e2a1 /usr.bin | |
parent | c3f2c4d7f4360d20209889b3471d84699a34a179 (diff) |
Make sure rcs_lock_add() and rcs_lock_remove() properly update the
rd_lock member of the matching delta.
Other keyword substitution will not properly work in cases where the
RCS file did not have a lock for the revision yet or if the lock is
being removed.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rcs/rcs.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c index 403e2c2f3bc..f4aca8cd97c 100644 --- a/usr.bin/rcs/rcs.c +++ b/usr.bin/rcs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.86 2018/12/30 23:09:58 guenther Exp $ */ +/* $OpenBSD: rcs.c,v 1.87 2019/01/09 17:55:28 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -691,6 +691,12 @@ int rcs_lock_add(RCSFILE *file, const char *user, RCSNUM *rev) { struct rcs_lock *lkp; + struct rcs_delta *rdp; + + if ((rdp = rcs_findrev(file, rev)) == NULL) { + rcs_errno = RCS_ERR_NOENT; + return (-1); + } /* first look for duplication */ TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) { @@ -706,6 +712,9 @@ rcs_lock_add(RCSFILE *file, const char *user, RCSNUM *rev) lkp->rl_num = rcsnum_alloc(); rcsnum_cpy(rev, lkp->rl_num, 0); + free(rdp->rd_locker); + rdp->rd_locker = xstrdup(user); + TAILQ_INSERT_TAIL(&(file->rf_locks), lkp, rl_list); /* not synced anymore */ @@ -724,6 +733,12 @@ int rcs_lock_remove(RCSFILE *file, const char *user, RCSNUM *rev) { struct rcs_lock *lkp; + struct rcs_delta *rdp; + + if ((rdp = rcs_findrev(file, rev)) == NULL) { + rcs_errno = RCS_ERR_NOENT; + return (-1); + } TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) { if (strcmp(lkp->rl_name, user) == 0 && @@ -741,6 +756,9 @@ rcs_lock_remove(RCSFILE *file, const char *user, RCSNUM *rev) free(lkp->rl_name); free(lkp); + free(rdp->rd_locker); + rdp->rd_locker = NULL; + /* not synced anymore */ file->rf_flags &= ~RCS_SYNCED; return (0); |