[Pkg-gnupg-commit] [gnupg2] 130/292: common: Fix copying data to estreams.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:34 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 8dce5ee55a0268d196023224dcf3020306922490
Author: Justus Winter <justus at g10code.com>
Date:   Tue Oct 18 17:57:19 2016 +0200

    common: Fix copying data to estreams.
    
    * common/exectool.c (copy_buffer_do_copy): Correctly account for
    partially written data in the event of errors.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 common/exectool.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/exectool.c b/common/exectool.c
index e46071c..cf54efe 100644
--- a/common/exectool.c
+++ b/common/exectool.c
@@ -248,7 +248,14 @@ copy_buffer_do_copy (struct copy_buffer *c, estream_t source, estream_t sink)
     return 0;	/* Done copying.  */
 
 
+  nwritten = 0;
   err = sink? es_write (sink, c->writep, c->nread, &nwritten) : 0;
+
+  assert (nwritten <= c->nread);
+  c->writep += nwritten;
+  c->nread -= nwritten;
+  assert (c->writep - c->buffer <= sizeof c->buffer);
+
   if (err)
     {
       if (errno == EAGAIN)
@@ -257,11 +264,6 @@ copy_buffer_do_copy (struct copy_buffer *c, estream_t source, estream_t sink)
       return my_error_from_syserror ();
     }
 
-  assert (nwritten <= c->nread);
-  c->writep += nwritten;
-  c->nread -= nwritten;
-  assert (c->writep - c->buffer <= sizeof c->buffer);
-
   if (sink && es_fflush (sink) && errno != EAGAIN)
     err = my_error_from_syserror ();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list