From f0b9c78f7777848f3d00ae19283090535ad65693 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Sat, 27 May 2006 11:59:44 +0000 Subject: [PATCH] Check cvs commit's -m argument for being a filename and ask the user if he is serious. This should in the future prevent log messages like "/tmp/mycommit.txt", which happen when -m is used instead of -F. --- gnu/usr.bin/cvs/cvs/Makefile | 4 +- gnu/usr.bin/cvs/cvs/commit.c.patch | 67 ++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 gnu/usr.bin/cvs/cvs/commit.c.patch diff --git a/gnu/usr.bin/cvs/cvs/Makefile b/gnu/usr.bin/cvs/cvs/Makefile index 70b5292e2d..1cfe003766 100644 --- a/gnu/usr.bin/cvs/cvs/Makefile +++ b/gnu/usr.bin/cvs/cvs/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/gnu/usr.bin/cvs/cvs/Makefile,v 1.32.2.6 2003/01/21 23:06:51 peter Exp $ -# $DragonFly: src/gnu/usr.bin/cvs/cvs/Makefile,v 1.10 2005/12/07 13:42:57 corecode Exp $ +# $DragonFly: src/gnu/usr.bin/cvs/cvs/Makefile,v 1.11 2006/05/27 11:59:44 corecode Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -25,7 +25,7 @@ SRCS= add.c admin.c annotate.c buffer.c \ update.c vers_ts.c version.c watch.c wrapper.c zlib.c \ main.c diff.c ${PATCHES} -PATCHES=main.c.patch diff.c.patch root.c.patch rcs.c.patch \ +PATCHES=main.c.patch commit.c.patch diff.c.patch root.c.patch rcs.c.patch \ parseinfo.c.patch cvs.h.patch zlib.c.patch CONTRIBDIR= ${CVSDIR}/src diff --git a/gnu/usr.bin/cvs/cvs/commit.c.patch b/gnu/usr.bin/cvs/cvs/commit.c.patch new file mode 100644 index 0000000000..d125838eef --- /dev/null +++ b/gnu/usr.bin/cvs/cvs/commit.c.patch @@ -0,0 +1,67 @@ +$DragonFly: src/gnu/usr.bin/cvs/cvs/Attic/commit.c.patch,v 1.1 2006/05/27 11:59:44 corecode Exp $ +Index: src/commit.c +=================================================================== +RCS file: /cvs/src/contrib/cvs-1.12/src/commit.c,v +retrieving revision 1.1.1.1 +diff -u -r1.1.1.1 commit.c +--- src/commit.c 7 Dec 2005 00:15:16 -0000 1.1.1.1 ++++ src/commit.c 27 May 2006 09:20:10 -0000 +@@ -443,6 +443,58 @@ + ++saved_tag; + } + ++ /* Check if the user passed -m, but wanted -F */ ++ if (saved_message) ++ { ++ int fd; ++ ++ fd = open(saved_message, O_RDONLY); ++ /* valid fd -> possibly wrong flag? */ ++ if (fd >= 0) ++ { ++ char *line = NULL; ++ size_t line_alloced = 0; ++ int line_len; ++ ++ close(fd); ++ ++ for (;;) { ++ printf("The message you passed exists as a file\n"); ++ printf("a)bort, c)ontinue, treat as f)ile name\n"); ++ printf("Action: (abort) "); ++ fflush(stdout); ++ line_len = getline(&line, &line_alloced, stdin); ++ if (line_len < 0) ++ { ++ error(0, errno, "cannot read from stdin"); ++ error(1, 0, "aborting"); ++ } ++ else if (line_len == 0 || *line == '\n' || *line == 'a' || *line == 'A') ++ { ++ error(1, 0, "aborted by user"); ++ } ++ else if (*line == 'c' || *line == 'C') ++ { ++ break; ++ } ++ else if (*line == 'f' || *line == 'F') ++ { ++ /* ++ * We are leaking the memory for the file name, ++ * but who really cares? ++ */ ++ logfile = saved_message; ++ saved_message = NULL; ++ break; ++ } ++ printf("Unknown input\n"); ++ } ++ ++ if (line != NULL) ++ free(line); ++ } ++ } ++ + /* some checks related to the "-F logfile" option */ + if (logfile) + { -- 2.41.0