bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

failure to append to .cvspass should always be fatal


From: Jim Meyering
Subject: failure to append to .cvspass should always be fatal
Date: Sun, 27 Feb 2005 11:53:14 +0100

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  <jim@meyering.net>

        * 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. */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]