When a `login' commands leads to appending to .cvspass, that file is
copied to a stream opened on a temporary file, and the new entry is
appended.  While failing to open or fwrite the temporary file evokes an
`error (1, ...', a failed fclose gets only a warning:

        if ((fp = CVS_FOPEN (passfile, "a")) == NULL)
            error (1, errno, "could not open %s for writing", passfile);

        if (fprintf (fp, "/1 %s %s\n", cvsroot_canonical, newpassword) == EOF)
            error (1, errno, "cannot write %s", passfile);
        if (fclose (fp) < 0)
            error (0, errno, "cannot close %s", passfile);

Admittedly, it's pretty unlikely that an append would fail in the first
place.  But if cvs fails for an even less likely fprintf write failure,
then it should also fail for an fclose-induced write failure.  Since there
is no comment explaining the discrepancy, I assume it was an oversight.

Here's the fix:

2005-02-27  Jim Meyering  <[EMAIL PROTECTED]>

        * login.c (password_entry_operation): Exit nonzero when failing
        to close a just-appended-to .cvspass file.

Index: src/login.c
===================================================================
RCS file: /cvs/ccvs/src/login.c,v
retrieving revision 1.82
diff -u -p -r1.82 login.c
--- src/login.c 1 Feb 2005 22:20:06 -0000       1.82
+++ src/login.c 27 Feb 2005 10:47:58 -0000
@@ -456,7 +456,7 @@ process:
        if (fprintf (fp, "/1 %s %s\n", cvsroot_canonical, newpassword) == EOF)
            error (1, errno, "cannot write %s", passfile);
        if (fclose (fp) < 0)
-           error (0, errno, "cannot close %s", passfile);
+           error (1, errno, "cannot close %s", passfile);
     }
 
     /* Utter, total, raving paranoia, I know. */


_______________________________________________
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs

Reply via email to