Mon May 30 17:49:51 2016 UTC ()
Make sure that all messages end in '\n' in make_message_rcsvalid() and
compensate for it in add_rcs_file().


(christos)
diff -r1.6 -r1.7 src/external/gpl2/xcvs/dist/src/import.c
diff -r1.3 -r1.4 src/external/gpl2/xcvs/dist/src/subr.c

cvs diff -r1.6 -r1.7 src/external/gpl2/xcvs/dist/src/import.c (expand / switch to unified diff)

--- src/external/gpl2/xcvs/dist/src/import.c 2016/05/17 14:00:09 1.6
+++ src/external/gpl2/xcvs/dist/src/import.c 2016/05/30 17:49:51 1.7
@@ -11,27 +11,27 @@ @@ -11,27 +11,27 @@
11 * specified in the README file that comes with the CVS source distribution. 11 * specified in the README file that comes with the CVS source distribution.
12 *  12 *
13 * "import" checks in the vendor release located in the current directory into 13 * "import" checks in the vendor release located in the current directory into
14 * the CVS source repository. The CVS vendor branch support is utilized. 14 * the CVS source repository. The CVS vendor branch support is utilized.
15 *  15 *
16 * At least three arguments are expected to follow the options: 16 * At least three arguments are expected to follow the options:
17 * repository Where the source belongs relative to the CVSROOT 17 * repository Where the source belongs relative to the CVSROOT
18 * VendorTag Vendor's major tag 18 * VendorTag Vendor's major tag
19 * VendorReleTag Tag for this particular release 19 * VendorReleTag Tag for this particular release
20 * 20 *
21 * Additional arguments specify more Vendor Release Tags. 21 * Additional arguments specify more Vendor Release Tags.
22 */ 22 */
23#include <sys/cdefs.h> 23#include <sys/cdefs.h>
24__RCSID("$NetBSD: import.c,v 1.6 2016/05/17 14:00:09 christos Exp $"); 24__RCSID("$NetBSD: import.c,v 1.7 2016/05/30 17:49:51 christos Exp $");
25 25
26#include "cvs.h" 26#include "cvs.h"
27#include "lstat.h" 27#include "lstat.h"
28#include "save-cwd.h" 28#include "save-cwd.h"
29 29
30static char *get_comment (const char *user); 30static char *get_comment (const char *user);
31static int add_rev (char *message, RCSNode *rcs, char *vfile, 31static int add_rev (char *message, RCSNode *rcs, char *vfile,
32 char *vers); 32 char *vers);
33static int add_tags (RCSNode *rcs, char *vfile, char *vtag, int targc, 33static int add_tags (RCSNode *rcs, char *vfile, char *vtag, int targc,
34 char *targv[]); 34 char *targv[]);
35static int import_descend (char *message, char *vtag, int targc, char *targv[]); 35static int import_descend (char *message, char *vtag, int targc, char *targv[]);
36static int import_descend_dir (char *message, char *dir, char *vtag, 36static int import_descend_dir (char *message, char *dir, char *vtag,
37 int targc, char *targv[]); 37 int targc, char *targv[]);
@@ -1399,61 +1399,61 @@ add_rcs_file (const char *message, const @@ -1399,61 +1399,61 @@ add_rcs_file (const char *message, const
1399 goto write_error; 1399 goto write_error;
1400 } 1400 }
1401 1401
1402 if (add_vhead != NULL) 1402 if (add_vhead != NULL)
1403 { 1403 {
1404 if (fprintf (fprcs, "\012%s\012", add_vhead) < 0 || 1404 if (fprintf (fprcs, "\012%s\012", add_vhead) < 0 ||
1405 fprintf (fprcs, "log\012@") < 0) 1405 fprintf (fprcs, "log\012@") < 0)
1406 goto write_error; 1406 goto write_error;
1407 if (add_vbranch != NULL) 1407 if (add_vbranch != NULL)
1408 { 1408 {
1409 /* We are going to put the log message in the revision on the 1409 /* We are going to put the log message in the revision on the
1410 branch. So putting it here too seems kind of redundant, I 1410 branch. So putting it here too seems kind of redundant, I
1411 guess (and that is what CVS has always done, anyway). */ 1411 guess (and that is what CVS has always done, anyway). */
1412 if (fprintf (fprcs, "Initial revision") < 0) 1412 if (fprintf (fprcs, "Initial revision\n") < 0)
1413 goto write_error; 1413 goto write_error;
1414 } 1414 }
1415 else 1415 else
1416 { 1416 {
1417 if (expand_at_signs (message, (off_t) strlen (message), fprcs) < 0) 1417 if (expand_at_signs (message, (off_t) strlen (message), fprcs) < 0)
1418 goto write_error; 1418 goto write_error;
1419 } 1419 }
1420 if (fprintf (fprcs, "\012@\012") < 0 || 1420 if (fprintf (fprcs, "@\012") < 0 ||
1421 fprintf (fprcs, "text\012@") < 0) 1421 fprintf (fprcs, "text\012@") < 0)
1422 { 1422 {
1423 goto write_error; 1423 goto write_error;
1424 } 1424 }
1425 1425
1426 /* Now copy over the contents of the file, expanding at signs. 1426 /* Now copy over the contents of the file, expanding at signs.
1427 * If config->preserve_perms is set, do this only for regular files. 1427 * If config->preserve_perms is set, do this only for regular files.
1428 */ 1428 */
1429 if (!do_killnew) 1429 if (!do_killnew)
1430 { 1430 {
1431 /* Now copy over the contents of the file, expanding at signs, 1431 /* Now copy over the contents of the file, expanding at signs,
1432 if not done as part of do_killnew handling above. */ 1432 if not done as part of do_killnew handling above. */
1433 if (expand_and_copy_contents (fprcs, file_type, user, fpuser)) 1433 if (expand_and_copy_contents (fprcs, file_type, user, fpuser))
1434 goto write_error; 1434 goto write_error;
1435 } 1435 }
1436 1436
1437 if (fprintf (fprcs, "@\012\012") < 0) 1437 if (fprintf (fprcs, "@\012\012") < 0)
1438 goto write_error; 1438 goto write_error;
1439 1439
1440 if (add_vbranch != NULL) 1440 if (add_vbranch != NULL)
1441 { 1441 {
1442 if (fprintf (fprcs, "\012%s.1\012", add_vbranch) < 0 || 1442 if (fprintf (fprcs, "\012%s.1\012", add_vbranch) < 0 ||
1443 fprintf (fprcs, "log\012@") < 0 || 1443 fprintf (fprcs, "log\012@") < 0 ||
1444 expand_at_signs (message, 1444 expand_at_signs (message,
1445 (off_t) strlen (message), fprcs) < 0 || 1445 (off_t) strlen (message), fprcs) < 0 ||
1446 fprintf (fprcs, "\012@\012text\012") < 0 || 1446 fprintf (fprcs, "@\012text\012") < 0 ||
1447 fprintf (fprcs, "@@\012") < 0) 1447 fprintf (fprcs, "@@\012") < 0)
1448 goto write_error; 1448 goto write_error;
1449 } 1449 }
1450 } 1450 }
1451 1451
1452 if (fclose (fprcs) == EOF) 1452 if (fclose (fprcs) == EOF)
1453 { 1453 {
1454 ierrno = errno; 1454 ierrno = errno;
1455 goto write_error_noclose; 1455 goto write_error_noclose;
1456 } 1456 }
1457 /* Close fpuser only if we opened it to begin with. */ 1457 /* Close fpuser only if we opened it to begin with. */
1458 if (fpuser != NULL) 1458 if (fpuser != NULL)
1459 { 1459 {

cvs diff -r1.3 -r1.4 src/external/gpl2/xcvs/dist/src/subr.c (expand / switch to unified diff)

--- src/external/gpl2/xcvs/dist/src/subr.c 2016/05/17 14:00:09 1.3
+++ src/external/gpl2/xcvs/dist/src/subr.c 2016/05/30 17:49:51 1.4
@@ -3,27 +3,27 @@ @@ -3,27 +3,27 @@
3 * 3 *
4 * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, 4 * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>,
5 * and others. 5 * and others.
6 * 6 *
7 * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk 7 * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk
8 * Portions Copyright (C) 1989-1992, Brian Berliner 8 * Portions Copyright (C) 1989-1992, Brian Berliner
9 *  9 *
10 * You may distribute under the terms of the GNU General Public License as 10 * You may distribute under the terms of the GNU General Public License as
11 * specified in the README file that comes with the CVS source distribution. 11 * specified in the README file that comes with the CVS source distribution.
12 *  12 *
13 * Various useful functions for the CVS support code. 13 * Various useful functions for the CVS support code.
14 */ 14 */
15#include <sys/cdefs.h> 15#include <sys/cdefs.h>
16__RCSID("$NetBSD: subr.c,v 1.3 2016/05/17 14:00:09 christos Exp $"); 16__RCSID("$NetBSD: subr.c,v 1.4 2016/05/30 17:49:51 christos Exp $");
17 17
18#include "cvs.h" 18#include "cvs.h"
19 19
20#include "canonicalize.h" 20#include "canonicalize.h"
21#include "canon-host.h" 21#include "canon-host.h"
22#include "getline.h" 22#include "getline.h"
23#include "vasprintf.h" 23#include "vasprintf.h"
24#include "vasnprintf.h" 24#include "vasnprintf.h"
25 25
26/* Get wint_t. */ 26/* Get wint_t. */
27#ifdef HAVE_WINT_T 27#ifdef HAVE_WINT_T
28# include <wchar.h> 28# include <wchar.h>
29#endif 29#endif
@@ -532,49 +532,55 @@ check_numeric (const char *rev, int argc @@ -532,49 +532,55 @@ check_numeric (const char *rev, int argc
532 * 532 *
533 * TODO: We no longer use RCS to manage repository files, so maybe this 533 * TODO: We no longer use RCS to manage repository files, so maybe this
534 * nonsense about non-empty log fields can be dropped. 534 * nonsense about non-empty log fields can be dropped.
535 */ 535 */
536char * 536char *
537make_message_rcsvalid (const char *message) 537make_message_rcsvalid (const char *message)
538{ 538{
539 char *dst, *dp; 539 char *dst, *dp;
540 const char *mp; 540 const char *mp;
541 541
542 if (message == NULL) message = ""; 542 if (message == NULL) message = "";
543 543
544 /* Strip whitespace from end of lines and end of string. */ 544 /* Strip whitespace from end of lines and end of string. */
545 dp = dst = (char *) xmalloc (strlen (message) + 1); 545 /* One for NUL, one for \n */
 546 dp = dst = xmalloc (strlen (message) + 2);
546 for (mp = message; *mp != '\0'; ++mp) 547 for (mp = message; *mp != '\0'; ++mp)
547 { 548 {
548 if (*mp == '\n') 549 if (*mp == '\n')
549 { 550 {
550 /* At end-of-line; backtrack to last non-space. */ 551 /* At end-of-line; backtrack to last non-space. */
551 while (dp > dst && (dp[-1] == ' ' || dp[-1] == '\t')) 552 while (dp > dst && (dp[-1] == ' ' || dp[-1] == '\t'))
552 --dp; 553 --dp;
553 } 554 }
554 *dp++ = *mp; 555 *dp++ = *mp;
555 } 556 }
556 557
557 /* Backtrack to last non-space at end of string, and truncate. */ 558 /* Backtrack to last non-space at end of string, and truncate. */
558 while (dp > dst && isspace ((unsigned char) dp[-1])) 559 while (dp > dst && isspace ((unsigned char) dp[-1]))
559 --dp; 560 --dp;
560 *dp = '\0'; 561 *dp = '\0';
561 562
562 /* After all that, if there was no non-space in the string, 563 /* After all that, if there was no non-space in the string,
563 substitute a non-empty message. */ 564 substitute a non-empty message. */
564 if (*dst == '\0') 565 if (*dst == '\0')
565 { 566 {
566 free (dst); 567 free (dst);
567 dst = xstrdup ("*** empty log message ***"); 568 dst = xstrdup ("*** empty log message ***\n");
 569 }
 570 else if (dp > dst && dp[-1] != '\n')
 571 {
 572 *dp++ = '\n';
 573 *dp++ = '\0';
568 } 574 }
569 575
570 return dst; 576 return dst;
571} 577}
572 578
573 579
574 580
575/* Does the file FINFO contain conflict markers? The whole concept 581/* Does the file FINFO contain conflict markers? The whole concept
576 of looking at the contents of the file to figure out whether there are 582 of looking at the contents of the file to figure out whether there are
577 unresolved conflicts is kind of bogus (people do want to manage files 583 unresolved conflicts is kind of bogus (people do want to manage files
578 which contain those patterns not as conflict markers), but for now it 584 which contain those patterns not as conflict markers), but for now it
579 is what we do. */ 585 is what we do. */
580int 586int