cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog buffer.c commit.c filesubr.c... [cvs1-11-x-


From: Mark D. Baushke
Subject: [Cvs-cvs] ccvs/src ChangeLog buffer.c commit.c filesubr.c... [cvs1-11-x-branch]
Date: Thu, 04 May 2006 09:53:10 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Branch:         cvs1-11-x-branch
Changes by:     Mark D. Baushke <address@hidden>        06/05/04 09:53:09

Modified files:
        src            : ChangeLog buffer.c commit.c filesubr.c import.c 
                         login.c logmsg.c patch.c 

Log message:
        * filesubr.c (cvs_temp_file): Avoid keeping pointers to free()'d
        storage laying around.
        * commit.c (commit): Handle possible NULL filename values
        returned from cvs_temp_file().
        * filesubr.c (cvs_temp_name): Ditto.
        * import.c (import): Ditto.
        * login.c (password_entry_operation): Ditto.
        * logmsg.c (do_verify): Ditto.
        * patch.c (patch_fileproc): Ditto.
        [Fixes NetBSD coverity cid-2545.]
        
        * buffer.c (packetizing_buffer_output): Initialize outdata.
        [Fixes NetBSD coverity cid-2474.]

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/ChangeLog.diff?only_with_tag=cvs1-11-x-branch&tr1=1.2336.2.441&tr2=1.2336.2.442&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/buffer.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.21.4.14&tr2=1.21.4.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/commit.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.187.4.35&tr2=1.187.4.36&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/filesubr.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.59.4.19&tr2=1.59.4.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/import.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.133.4.16&tr2=1.133.4.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/login.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.70.4.6&tr2=1.70.4.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/logmsg.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.62.4.9&tr2=1.62.4.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/patch.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.80.4.14&tr2=1.80.4.15&r1=text&r2=text

Patches:
Index: ccvs/src/ChangeLog
diff -u ccvs/src/ChangeLog:1.2336.2.441 ccvs/src/ChangeLog:1.2336.2.442
--- ccvs/src/ChangeLog:1.2336.2.441     Thu May  4 07:52:17 2006
+++ ccvs/src/ChangeLog  Thu May  4 09:53:08 2006
@@ -1,5 +1,19 @@
 2006-05-04  Mark D. Baushke  <address@hidden>
 
+       * filesubr.c (cvs_temp_file): Avoid keeping pointers to free()'d
+       storage laying around.
+       * commit.c (commit): Handle possible NULL filename values
+       returned from cvs_temp_file().
+       * filesubr.c (cvs_temp_name): Ditto.
+       * import.c (import): Ditto.
+       * login.c (password_entry_operation): Ditto.
+       * logmsg.c (do_verify): Ditto.
+       * patch.c (patch_fileproc): Ditto.
+       [Fixes NetBSD coverity cid-2545.]
+
+       * buffer.c (packetizing_buffer_output): Initialize outdata.
+       [Fixes NetBSD coverity cid-2474.]
+
        * server.c (server_updated): Check for NULL return from
        findnode_fn(). [Fixes NetBSD coverity cid-1352.]
 
Index: ccvs/src/buffer.c
diff -u ccvs/src/buffer.c:1.21.4.14 ccvs/src/buffer.c:1.21.4.15
--- ccvs/src/buffer.c:1.21.4.14 Wed Dec  7 08:04:48 2005
+++ ccvs/src/buffer.c   Thu May  4 09:53:09 2006
@@ -1860,7 +1860,7 @@
     struct packetizing_buffer *pb = (struct packetizing_buffer *) closure;
     char inbuf[BUFFER_DATA_SIZE + 2];
     char stack_outbuf[BUFFER_DATA_SIZE + PACKET_SLOP + 4];
-    struct buffer_data *outdata;
+    struct buffer_data *outdata = NULL;
     char *outbuf;
     int size, status, translated;
 
@@ -1915,6 +1915,11 @@
        buf_output (pb->buf, outbuf, translated + 2);
     else
     {
+       /* if ((have + PACKET_SLOP + 4) > BUFFER_DATA_SIZE), then
+          outdata may be NULL. */
+       if (outdata == NULL)
+           abort ();
+
        outdata->size = translated + 2;
        buf_append_data (pb->buf, outdata, outdata);
     }
Index: ccvs/src/commit.c
diff -u ccvs/src/commit.c:1.187.4.35 ccvs/src/commit.c:1.187.4.36
--- ccvs/src/commit.c:1.187.4.35        Mon Jan  9 21:19:16 2006
+++ ccvs/src/commit.c   Thu May  4 09:53:09 2006
@@ -643,7 +643,8 @@
 
            fp = cvs_temp_file (&fname);
            if (fp == NULL)
-               error (1, 0, "cannot create temporary file %s", fname);
+               error (1, 0, "cannot create temporary file %s",
+                      fname ? fname : "(null)");
            if (fwrite (saved_message, 1, strlen (saved_message), fp)
                != strlen (saved_message))
                error (1, errno, "cannot write temporary file %s", fname);
Index: ccvs/src/filesubr.c
diff -u ccvs/src/filesubr.c:1.59.4.19 ccvs/src/filesubr.c:1.59.4.20
--- ccvs/src/filesubr.c:1.59.4.19       Fri Apr  7 01:48:51 2006
+++ ccvs/src/filesubr.c Thu May  4 09:53:09 2006
@@ -702,7 +702,8 @@
 
     fp = cvs_temp_file (&fn);
     if (fp == NULL)
-       error (1, errno, "Failed to create temporary file");
+       error (1, errno, "Failed to create temporary file %s",
+              fn ? fn : "(null)");
     if (fclose (fp) == EOF)
        error (0, errno, "Failed to close temporary file %s", fn);
     return fn;
@@ -739,7 +740,8 @@
  * NFS locking thing, but until I hear of more problems, I'm not going to
  * bother.
  */
-FILE *cvs_temp_file (filename)
+FILE *
+cvs_temp_file (filename)
     char **filename;
 {
     char *fn;
@@ -778,7 +780,11 @@
        errno = save_errno;
     }
 
-    if (fp == NULL) free (fn);
+    if (fp == NULL)
+    {
+       free (fn);
+       fn = NULL;
+    }
     /* mkstemp is defined to open mode 0600 using glibc 2.0.7+ */
     /* FIXME - configure can probably tell us which version of glibc we are
      * linking to and not chmod for 2.0.7+
@@ -793,7 +799,11 @@
 
     fn = tempnam (Tmpdir, "cvs");
     if (fn == NULL) fp = NULL;
-    else if ((fp = CVS_FOPEN (fn, "w+")) == NULL) free (fn);
+    else if ((fp = CVS_FOPEN (fn, "w+")) == NULL)
+    {
+       free (fn);
+       fn = NULL;
+    }
     else chmod (fn, 0600);
 
     /* tempnam returns a pointer to a newly malloc'd string, so there's
@@ -843,6 +853,11 @@
 #endif
 
     *filename = fn;
+    if (fn == NULL && fp != NULL)
+    {
+       fclose (fp);
+       fp = NULL;
+    }
     return fp;
 }
 
Index: ccvs/src/import.c
diff -u ccvs/src/import.c:1.133.4.16 ccvs/src/import.c:1.133.4.17
--- ccvs/src/import.c:1.133.4.16        Fri Sep  2 19:37:33 2005
+++ ccvs/src/import.c   Thu May  4 09:53:09 2006
@@ -317,7 +317,8 @@
 
     /* Create the logfile that will be logged upon completion */
     if ((logfp = cvs_temp_file (&tmpfile)) == NULL)
-       error (1, errno, "cannot create temporary file `%s'", tmpfile);
+       error (1, errno, "cannot create temporary file `%s'",
+              tmpfile ? tmpfile : "(null)");
     /* On systems where we can unlink an open file, do so, so it will go
        away no matter how we exit.  FIXME-maybe: Should be checking for
        errors but I'm not sure which error(s) we get if we are on a system
Index: ccvs/src/login.c
diff -u ccvs/src/login.c:1.70.4.6 ccvs/src/login.c:1.70.4.7
--- ccvs/src/login.c:1.70.4.6   Mon Apr 18 17:36:45 2005
+++ ccvs/src/login.c    Thu May  4 09:53:09 2006
@@ -387,7 +387,8 @@
 
        /* create and open a temp file */
        if ((tmp_fp = cvs_temp_file (&tmp_name)) == NULL)
-           error (1, errno, "unable to open temp file %s", tmp_name);
+           error (1, errno, "unable to open temp file %s",
+                  tmp_name ? tmp_name : "(null)");
 
        line = 0;
        while ((line_length = getline (&linebuf, &linebuf_len, fp)) >= 0)
Index: ccvs/src/logmsg.c
diff -u ccvs/src/logmsg.c:1.62.4.9 ccvs/src/logmsg.c:1.62.4.10
--- ccvs/src/logmsg.c:1.62.4.9  Fri Sep  2 19:37:34 2005
+++ ccvs/src/logmsg.c   Thu May  4 09:53:09 2006
@@ -439,7 +439,8 @@
        temp file, and close the file.  */
 
     if ((fp = cvs_temp_file (&fname)) == NULL)
-       error (1, errno, "cannot create temporary file %s", fname);
+       error (1, errno, "cannot create temporary file %s",
+              fname ? fname : "(null)");
 
     if (*messagep != NULL)
        fputs (*messagep, fp);
@@ -545,7 +546,7 @@
     if (unlink_file (fname) < 0)
        error (0, errno, "cannot remove %s", fname);
     free (fname);
-    free( verifymsg_script );
+    free (verifymsg_script);
     verifymsg_script = NULL;
 }
 
Index: ccvs/src/patch.c
diff -u ccvs/src/patch.c:1.80.4.14 ccvs/src/patch.c:1.80.4.15
--- ccvs/src/patch.c:1.80.4.14  Thu Sep 22 20:09:30 2005
+++ ccvs/src/patch.c    Thu May  4 09:53:09 2006
@@ -518,7 +518,8 @@
      */
     if ((fp1 = cvs_temp_file (&tmpfile1)) == NULL)
     {
-       error (0, errno, "cannot create temporary file %s", tmpfile1);
+       error (0, errno, "cannot create temporary file %s",
+              tmpfile1 ? tmpfile1 : "(null)");
        ret = 1;
        goto out;
     }
@@ -527,7 +528,8 @@
            error (0, errno, "warning: cannot close %s", tmpfile1);
     if ((fp2 = cvs_temp_file (&tmpfile2)) == NULL)
     {
-       error (0, errno, "cannot create temporary file %s", tmpfile2);
+       error (0, errno, "cannot create temporary file %s",
+              tmpfile2 ? tmpfile2 : "(null)");
        ret = 1;
        goto out;
     }
@@ -536,7 +538,8 @@
            error (0, errno, "warning: cannot close %s", tmpfile2);
     if ((fp3 = cvs_temp_file (&tmpfile3)) == NULL)
     {
-       error (0, errno, "cannot create temporary file %s", tmpfile3);
+       error (0, errno, "cannot create temporary file %s",
+              tmpfile3 ? tmpfile3 : "(null)");
        ret = 1;
        goto out;
     }
@@ -752,16 +755,28 @@
         free (line1);
     if (line2)
         free (line2);
-    if (CVS_UNLINK (tmpfile1) < 0)
-       error (0, errno, "cannot unlink %s", tmpfile1);
-    if (CVS_UNLINK (tmpfile2) < 0)
-       error (0, errno, "cannot unlink %s", tmpfile2);
-    if (CVS_UNLINK (tmpfile3) < 0)
-       error (0, errno, "cannot unlink %s", tmpfile3);
-    free (tmpfile1);
-    free (tmpfile2);
-    free (tmpfile3);
-    tmpfile1 = tmpfile2 = tmpfile3 = NULL;
+    if (tmpfile1 != NULL)
+    {
+       if (CVS_UNLINK (tmpfile1) < 0)
+           error (0, errno, "cannot unlink %s", tmpfile1);
+       free (tmpfile1);
+       tmpfile1 = NULL;
+    }
+    if (tmpfile2 != NULL)
+    {
+       if (CVS_UNLINK (tmpfile2) < 0)
+           error (0, errno, "cannot unlink %s", tmpfile2);
+       free (tmpfile2);
+       tmpfile2 = NULL;
+    }
+    if (tmpfile3 != NULL)
+    {
+       if (CVS_UNLINK (tmpfile3) < 0)
+           error (0, errno, "cannot unlink %s", tmpfile3);
+       free (tmpfile3);
+       tmpfile3 = NULL;
+    }
+
     if (dargc)
     {
        run_arg_free_p (dargc, dargv);




reply via email to

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