diff options
Diffstat (limited to 'contrib/cvs/src/logmsg.c')
-rw-r--r-- | contrib/cvs/src/logmsg.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/contrib/cvs/src/logmsg.c b/contrib/cvs/src/logmsg.c index 7f83183c1549..0e26bce340de 100644 --- a/contrib/cvs/src/logmsg.c +++ b/contrib/cvs/src/logmsg.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.4 kit. + * specified in the README file that comes with the CVS source distribution. */ #include "cvs.h" @@ -282,7 +282,7 @@ do_editor (dir, messagep, repository, changes) (void) Parse_Info (CVSROOTADM_EDITINFO, repository, editinfo_proc, 0); /* run the editor */ - run_setup ("%s", editinfo_editor ? editinfo_editor : Editor); + run_setup (editinfo_editor ? editinfo_editor : Editor); run_arg (fname); if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL | RUN_SIGIGNORE)) != 0) @@ -345,8 +345,16 @@ do_editor (dir, messagep, repository, changes) (void) printf ("Action: (continue) "); (void) fflush (stdout); line_length = getline (&line, &line_chars_allocated, stdin); - if (line_length <= 0 - || *line == '\n' || *line == 'c' || *line == 'C') + if (line_length < 0) + { + error (0, errno, "cannot read from stdin"); + if (unlink_file (fname) < 0) + error (0, errno, + "warning: cannot remove temp file %s", fname); + error (1, 0, "aborting"); + } + else if (line_length == 0 + || *line == '\n' || *line == 'c' || *line == 'C') break; if (*line == 'a' || *line == 'A') { @@ -417,10 +425,7 @@ do_verify (messagep, repository) fp = fopen (fname, "w"); if (fp == NULL) - { error (1, errno, "cannot create temporary file %s", fname); - return; - } else { fprintf (fp, "%s", *messagep); @@ -440,10 +445,15 @@ do_verify (messagep, repository) if (verifymsg_script) { - run_setup ("%s", verifymsg_script); + run_setup (verifymsg_script); run_arg (fname); if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL | RUN_SIGIGNORE)) != 0) + { + /* Since following error() exits, delete the temp file + now. */ + unlink_file (fname); + error (1, retcode == -1 ? errno : 0, "Message verification failed"); } @@ -497,7 +507,7 @@ do_verify (messagep, repository) if (fclose (fp) < 0) error (0, errno, "warning: cannot close %s", fname); - /* Close and delete the temp file */ + /* Delete the temp file */ unlink_file (fname); free (fname); |