From 5609a1f867f37074b656532b8253edbdac6511f6 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Tue, 4 Mar 2008 16:43:52 +0000 Subject: fix segfault when trying to lock and unlock rcs files that contain no revisions. reported by Jean Raby. ok deraadt@ --- usr.bin/rcs/rcsprog.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index ac3356c9dd5..4354eead314 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.140 2008/02/24 15:13:18 xsa Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.141 2008/03/04 16:43:51 joris Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau * All rights reserved. @@ -436,6 +436,12 @@ rcs_main(int argc, char **argv) const char *username; char rev_str[RCS_REV_BUFSZ]; + if (file->rf_head == NULL) { + warnx("%s contains no revisions", fpath); + rcs_close(file); + continue; + } + if ((username = getlogin()) == NULL) err(1, "getlogin"); if (lrev == NULL) { @@ -462,6 +468,12 @@ rcs_main(int argc, char **argv) const char *username; char rev_str[RCS_REV_BUFSZ]; + if (file->rf_head == NULL) { + warnx("%s contains no revisions", fpath); + rcs_close(file); + continue; + } + if ((username = getlogin()) == NULL) err(1, "getlogin"); if (urev == NULL) { -- cgit v1.2.3