From: nicm Date: Tue, 13 Jul 2010 20:07:24 +0000 (+0000) Subject: Don't read before the beginning of the log message if it is zero-length X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a4b26cbabb9b1a0932d2a81ad8fe81b1724d70cc;p=openbsd Don't read before the beginning of the log message if it is zero-length (possible when it comes from stdin). Tweaked version of a fix from Peter Hendrickson in PR 6423. ok deraadt --- diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c index 67da998b226..1e51db144b5 100644 --- a/usr.bin/rcs/rcs.c +++ b/usr.bin/rcs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.55 2010/07/09 20:07:05 naddy Exp $ */ +/* $OpenBSD: rcs.c,v 1.56 2010/07/13 20:07:24 nicm Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -497,7 +497,7 @@ rcs_write(RCSFILE *rfp) if (rdp->rd_log != NULL) { len = strlen(rdp->rd_log); rcs_strprint((const u_char *)rdp->rd_log, len, fp); - if (rdp->rd_log[len-1] != '\n') + if (len == 0 || rdp->rd_log[len-1] != '\n') fputc('\n', fp); } fputs("@\ntext\n@", fp);