[git] GnuPG - branch, master, updated. gnupg-2.1.11-64-gf57a91a

by Neal H. Walfield cvs at cvs.gnupg.org
Tue Feb 23 21:15:05 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  f57a91afb69c58f9d8d9632801650f28c7dc1e0d (commit)
       via  33ac735a781325c4d47cdf6216813866ab93562e (commit)
       via  8066f8a3470f9d2f3682a28641a7b09eca29a105 (commit)
       via  903466e124841cb29f518afa6b7706d490737ac3 (commit)
      from  f7968db30b0e0ccae038e354568accb0a05d877c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f57a91afb69c58f9d8d9632801650f28c7dc1e0d
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Feb 23 21:14:21 2016 +0100

    common: Add log_assert.
    
    * common/logging.h (log_assert): New macro.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/common/logging.h b/common/logging.h
index c4ae5d0..d0b1597 100644
--- a/common/logging.h
+++ b/common/logging.h
@@ -81,6 +81,10 @@ void log_logv (int level, const char *fmt, va_list arg_ptr);
 void log_string (int level, const char *string);
 
 
+#define log_assert(expr)                                               \
+  do                                                                    \
+    if (! (expr)) log_bug ("Assertion " #expr " failed.\n");            \
+  while (0)
 void log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);
 void log_fatal (const char *fmt, ...)  GPGRT_ATTR_NR_PRINTF(1,2);
 void log_error (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);

commit 33ac735a781325c4d47cdf6216813866ab93562e
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Feb 23 21:07:09 2016 +0100

    gpg: Use higher-level functions.
    
    * g10/build-packet.c (do_symkey_enc): Use iobuf_write instead of
    iobuf_put in a loop.  Use iobuf_copy instead of iobuf_read and
    iobuf_write in a loop.  Move the memory wiping from here...
    * common/iobuf.c (iobuf_copy): ... to here.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/common/iobuf.c b/common/iobuf.c
index 1f2cd3f..a0d48c6 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2253,6 +2253,9 @@ iobuf_copy (iobuf_t dest, iobuf_t source)
         break;
       nwrote += nread;
     }
+
+  /* Burn the buffer.  */
+  wipememory (temp, sizeof (temp));
   xfree (temp);
 
   return nwrote;
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 4dec5b9..a6d5881 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -528,33 +528,23 @@ calc_plaintext( PKT_plaintext *pt )
 static int
 do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
 {
-    int i, rc = 0;
-    u32 n;
-    byte buf[1000]; /* this buffer has the plaintext! */
-    int nbytes;
+    int rc = 0;
+    size_t nbytes;
 
     write_header(out, ctb, calc_plaintext( pt ) );
     iobuf_put(out, pt->mode );
     iobuf_put(out, pt->namelen );
-    for(i=0; i < pt->namelen; i++ )
-	iobuf_put(out, pt->name[i] );
+    iobuf_write (out, pt->name, pt->namelen);
     rc = write_32(out, pt->timestamp );
     if (rc)
       return rc;
 
-    n = 0;
-    while( (nbytes=iobuf_read(pt->buf, buf, 1000)) != -1 ) {
-      rc = iobuf_write (out, buf, nbytes);
-      if (rc)
-        break;
-      n += nbytes;
-    }
-    wipememory(buf,1000); /* burn the buffer */
+    nbytes = iobuf_copy (out, pt->buf);
     if( (ctb&0x40) && !pt->len )
       iobuf_set_partial_body_length_mode(out, 0 ); /* turn off partial */
-    if( pt->len && n != pt->len )
+    if( pt->len && nbytes != pt->len )
       log_error("do_plaintext(): wrote %lu bytes but expected %lu bytes\n",
-		(ulong)n, (ulong)pt->len );
+		(ulong)nbytes, (ulong)pt->len );
 
     return rc;
 }

commit 8066f8a3470f9d2f3682a28641a7b09eca29a105
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Feb 23 21:04:29 2016 +0100

    common: Check for an error before reading.
    
    * common/iobuf.c (iobuf_copy): If DEST has a pending error, don't
    start copying.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/common/iobuf.c b/common/iobuf.c
index 6a9060a..1f2cd3f 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2237,6 +2237,9 @@ iobuf_copy (iobuf_t dest, iobuf_t source)
   assert (source->use == IOBUF_INPUT || source->use == IOBUF_INPUT_TEMP);
   assert (dest->use == IOBUF_OUTPUT || source->use == IOBUF_OUTPUT_TEMP);
 
+  if (iobuf_error (dest))
+    return -1;
+
   temp = xmalloc (temp_size);
   while (1)
     {

commit 903466e124841cb29f518afa6b7706d490737ac3
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Feb 23 20:36:07 2016 +0100

    common: More accurately name function.
    
    * common/iobuf.c (iobuf_set_partial_block_mode): Rename from this...
    (iobuf_set_partial_body_length_mode): ... to this.  Update callers.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/common/iobuf.c b/common/iobuf.c
index f5bbfb2..6a9060a 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2513,7 +2513,7 @@ iobuf_get_fname_nonnull (iobuf_t a)
  * LEN is the first length byte on read, but ignored on writes.
  */
 void
-iobuf_set_partial_block_mode (iobuf_t a, size_t len)
+iobuf_set_partial_body_length_mode (iobuf_t a, size_t len)
 {
   block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx);
 
diff --git a/common/iobuf.h b/common/iobuf.h
index 8ba02b3..785efdc 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -592,7 +592,7 @@ const char *iobuf_get_fname_nonnull (iobuf_t a);
    length headers (see Section 4.2.2.4 of RFC 4880).  Concretely, it
    just returns / writes the data and finishes the packet with an
    EOF.  */
-void iobuf_set_partial_block_mode (iobuf_t a, size_t len);
+void iobuf_set_partial_body_length_mode (iobuf_t a, size_t len);
 
 /* If PARTIAL is set, then read from the pipeline until the first EOF
    is returned.
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 4245208..4dec5b9 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -551,7 +551,7 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
     }
     wipememory(buf,1000); /* burn the buffer */
     if( (ctb&0x40) && !pt->len )
-      iobuf_set_partial_block_mode(out, 0 ); /* turn off partial */
+      iobuf_set_partial_body_length_mode(out, 0 ); /* turn off partial */
     if( pt->len && n != pt->len )
       log_error("do_plaintext(): wrote %lu bytes but expected %lu bytes\n",
 		(ulong)n, (ulong)pt->len );
@@ -1334,7 +1334,7 @@ write_new_header( IOBUF out, int ctb, u32 len, int hdrlen )
     if( iobuf_put(out, ctb ) )
 	return -1;
     if( !len ) {
-	iobuf_set_partial_block_mode(out, 512 );
+	iobuf_set_partial_body_length_mode(out, 512 );
     }
     else {
 	if( len < 192 ) {
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 38cd8c9..1be49b1 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -581,7 +581,7 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos,
             case PKT_ENCRYPTED:
             case PKT_ENCRYPTED_MDC:
             case PKT_COMPRESSED:
-              iobuf_set_partial_block_mode (inp, c & 0xff);
+              iobuf_set_partial_body_length_mode (inp, c & 0xff);
               pktlen = 0;	/* To indicate partial length.  */
               partial = 1;
               break;

-----------------------------------------------------------------------

Summary of changes:
 common/iobuf.c     |  8 +++++++-
 common/iobuf.h     |  2 +-
 common/logging.h   |  4 ++++
 g10/build-packet.c | 26 ++++++++------------------
 g10/parse-packet.c |  2 +-
 5 files changed, 21 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list