[Pkg-gnupg-commit] [gnupg2] 81/205: gpg: Allow the caller to write the contents of a plaintext packet.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed May 11 08:38:20 UTC 2016


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

dkg pushed a commit to branch experimental
in repository gnupg2.

commit 2fdb950471bd36f046672254ff26ca94797cc9f1
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Mar 2 15:35:39 2016 +0100

    gpg: Allow the caller to write the contents of a plaintext packet.
    
    * g10/build-packet.c (do_plaintext): Change the semantics such that if
    PT->BUF is NULL, it is the caller's responsibility to write the
    content (and disable partial body length mode, if appropriate).
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>
---
 g10/build-packet.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/g10/build-packet.c b/g10/build-packet.c
index 623533f..40c466b 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -618,7 +618,12 @@ calc_plaintext( PKT_plaintext *pt )
    after this much data has been read.)  If PT->LEN is 0 and CTB
    indicates that this is a new format packet, then partial block mode
    is assumed to have been enabled on OUT.  On success, partial block
-   mode is disabled.  */
+   mode is disabled.
+
+   If PT->BUF is NULL, the the caller must write out the data.  In
+   this case, if PT->LEN was 0, then partial body length mode was
+   enabled and the caller must disable it by calling
+   iobuf_set_partial_body_length_mode (out, 0).  */
 static int
 do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
 {
@@ -637,13 +642,16 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
     if (rc)
       return rc;
 
-    nbytes = iobuf_copy (out, pt->buf);
-    if(ctb_new_format_p (ctb) && !pt->len)
-      /* Turn off partial body length mode.  */
-      iobuf_set_partial_body_length_mode (out, 0);
-    if( pt->len && nbytes != pt->len )
-      log_error("do_plaintext(): wrote %lu bytes but expected %lu bytes\n",
-		(ulong)nbytes, (ulong)pt->len );
+    if (pt->buf)
+      {
+        nbytes = iobuf_copy (out, pt->buf);
+        if(ctb_new_format_p (ctb) && !pt->len)
+          /* Turn off partial body length mode.  */
+          iobuf_set_partial_body_length_mode (out, 0);
+        if( pt->len && nbytes != pt->len )
+          log_error("do_plaintext(): wrote %lu bytes but expected %lu bytes\n",
+                    (ulong)nbytes, (ulong)pt->len );
+      }
 
     return rc;
 }

-- 
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