CVS update: /ccvs/, /ccvs/src/

[email protected] 20 Apr 2005 20:55:04 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
User: dprice  
Date: 05/04/20 13:55:04

Modified:
 /ccvs/
  ChangeLog, NEWS
 /ccvs/src/
  ChangeLog, rcs.c, sanity.sh

Log:
 Merge changes from 1.11.x.

File Changes:

Directory: /ccvs/
=================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/ChangeLog?r1=1.1194&r2=1.1195
Delta lines:  +4 -0
-------------------
--- ChangeLog	18 Apr 2005 19:32:30 -0000	1.1194
+++ ChangeLog	20 Apr 2005 20:55:01 -0000	1.1195
@@ -1,3 +1,7 @@
+2005-04-20  Derek Price  <[email protected]>
+
+	* NEWS: Note log overflow fix.
+
 2005-04-15  Derek Price  <[email protected]>
 
 	* NEWS: Note Klocwork fixes.

File [changed]: NEWS
Url: https://ccvs.cvshome.org/source/browse/ccvs/NEWS?r1=1.312&r2=1.313
Delta lines:  +5 -0
-------------------
--- NEWS	18 Apr 2005 19:44:37 -0000	1.312
+++ NEWS	20 Apr 2005 20:55:01 -0000	1.313
@@ -1,6 +1,11 @@
 Changes since 1.12.12:
 **********************
 
+BUG FIXES
+
+* Thanks to an old report and patch from Stewart Brodie <[email protected]>, a
+  potential crash in response to a corrupt RCS file has been fixed.
+
 Changes from 1.12.11 to 1.12.12:
 ********************************
 

Directory: /ccvs/src/
=====================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/ChangeLog?r1=1.3171&r2=1.3172
Delta lines:  +7 -0
-------------------
--- ChangeLog	18 Apr 2005 19:32:32 -0000	1.3171
+++ ChangeLog	20 Apr 2005 20:55:01 -0000	1.3172
@@ -1,3 +1,10 @@
+2005-04-20  Derek Price  <[email protected]>
+
+	* rcs.c (expand_keywords): Avoid buffer overflow.
+	(Original patch from Stewart Brodie <[email protected]>.)
+
+	* sanity.sh (rcs5): New tests for the above.
+
 2005-04-08  Derek Price  <[email protected]>
 
 	* edit.c (edit_fileproc, unedit_fileproc): s/GMT/-0000/.

File [changed]: rcs.c
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/rcs.c?r1=1.345&r2=1.346
Delta lines:  +19 -0
--------------------
--- rcs.c	18 Apr 2005 19:32:32 -0000	1.345
+++ rcs.c	20 Apr 2005 20:55:02 -0000	1.346
@@ -3931,6 +3931,13 @@
 		if (*snl == '\n')
 		    ++cnl;
 
+	    /* If the log message did not end in a newline, increment
+	     * the newline count so we have space for the extra leader.
+	     * Failure to do so results in a buffer overrun.
+	     */
+	    if (loglen && snl[-1] != '\n')
+		++cnl;
+
 	    date = printable_date (ver->date);
 	    sub = xrealloc (sub,
 			    (sublen
@@ -3939,6 +3946,10 @@
 			     + strlen (date)
 			     + strlen (ver->author)
 			     + loglen
+			       /* Use CNL + 2 below:  One leader for each log
+				* line, plus the Revision/Author/Date line,
+				* plus a trailing blank line.
+				*/
 			     + (cnl + 2) * leader_len
 			     + 20));
 	    if (expand != KFLAG_V)
@@ -3978,6 +3989,14 @@
 			++slnl;
 		    memcpy (sub + sublen, sl, slnl - sl);
 		    sublen += slnl - sl;
+		    if (slnl == logend && slnl[-1] != '\n')
+		    {
+			/* There was no EOL at the end of the log message.  Add
+			 * one.
+			 */
+			sub[sublen] = '\n';
+			++sublen;
+		    }
 		    sl = slnl;
 		}
 	    }

File [changed]: sanity.sh
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/sanity.sh?r1=1.1054&r2=1.1055
Delta lines:  +51 -1
--------------------
--- sanity.sh	8 Apr 2005 18:17:01 -0000	1.1054
+++ sanity.sh	20 Apr 2005 20:55:02 -0000	1.1055
@@ -1634,7 +1634,8 @@
 	tests="${tests} serverpatch log log2 logopt ann ann-id"
 	# Repository Storage (RCS file format, CVS lock files, creating
 	# a repository without "cvs init", &c).
-	tests="${tests} crerepos rcs rcs2 rcs3 lockfiles backuprecover"
+	tests="${tests} crerepos rcs rcs2 rcs3 rcs5"
+	tests="$tests lockfiles backuprecover"
 	tests="${tests} sshstdio"
 	# More history browsing, &c.
 	tests="${tests} history"
@@ -22299,6 +22300,55 @@
 
 
 
+	rcs5)
+	  modify_repo mkdir $CVSROOT_DIRNAME/rcs5
+	  cat <<\EOF >$TESTDIR/file1,v
+head 1.1;
+access;
+symbols;
+locks;
+expand kv;
+
+1.1 date 2007.03.20.04.03.02; author jeremiah; state Ext;  branches; next;
+
+desc
+@@
+
+1.1
+log
+@he always had very fine wine@
+text
+@line1
+/*
+EOF
+echo ' * History: $''Log$' >>$TESTDIR/file1,v
+	  cat <<\EOF >>$TESTDIR/file1,v
+ */
+line5
+@
+EOF
+	  modify_repo mv $TESTDIR/file1,v $CVSROOT_DIRNAME/rcs5/file1,v
+
+          mkdir rcs5
+          cd rcs5
+	  dotest rcs5-1 "$testcvs -Q co rcs5"
+	  dotest rcs5-2 "cat rcs5/file1" \
+"line1
+/\\*
+ \\* History: "'\$'"Log: file1,v "'\$'"
+ \\* History: Revision 1\.1  2007/03/20 04:03:02  jeremiah
+ \\* History: he always had very fine wine
+ \\* History:
+ \\*/
+line5"
+
+	  cd ..
+          rm -r rcs5
+          modify_repo rm -rf $CVSROOT_DIRNAME/rcs5
+	  ;;
+
+
+
 	lockfiles)
 	  # Tests of CVS lock files.
 	  # TODO-maybe: Add a test where we arrange for a loginfo