[git] GnuPG - branch, master, updated. gnupg-2.1.7-69-gf076fa1

by Neal H. Walfield cvs at cvs.gnupg.org
Wed Sep 2 10:47:30 CEST 2015


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  f076fa190e09eab5c586650d81e241e0bb85ce25 (commit)
       via  219de84df9a8408fffedbb2600f5eb4c441950b6 (commit)
       via  f2d75ac7dc58f5ea59b231be6b83fea939b43ab8 (commit)
       via  5ff5e72b9c275fbd978136b1028bbf251af26e57 (commit)
       via  24259d856b6cbdd679035512a8fb7c042de8f02e (commit)
       via  8522cdc2264804d0677b7c0a447a0b45cf4195e3 (commit)
      from  9ba4ccdaf5e128fbea51ff142c63d4b359c7264d (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 f076fa190e09eab5c586650d81e241e0bb85ce25
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Sep 2 10:33:26 2015 +0200

    g10: If iobuf_seek fails when reading from the cache, do a hard read.
    
    * g10/keydb.c (keydb_get_keyblock): If the iobuf_seek fails when
    reading from the cache, then simply clear the cache and try reading
    from the database.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>.

diff --git a/g10/keydb.c b/g10/keydb.c
index b4877d4..124e940 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -1126,18 +1126,26 @@ keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb)
 
   if (keyblock_cache.state == KEYBLOCK_CACHE_FILLED)
     {
-      iobuf_seek (keyblock_cache.iobuf, 0);
-      err = parse_keyblock_image (keyblock_cache.iobuf,
-                                  keyblock_cache.pk_no,
-                                  keyblock_cache.uid_no,
-                                  keyblock_cache.sigstatus,
-                                  ret_kb);
+      err = iobuf_seek (keyblock_cache.iobuf, 0);
       if (err)
-        keyblock_cache_clear ();
-      if (DBG_CLOCK)
-        log_clock (err? "keydb_get_keyblock leave (cached, failed)"
-                      : "keydb_get_keyblock leave (cached)");
-      return err;
+	{
+	  log_error ("keydb_get_keyblock: failed to rewind iobuf for cache\n");
+	  keyblock_cache_clear ();
+	}
+      else
+	{
+	  err = parse_keyblock_image (keyblock_cache.iobuf,
+				      keyblock_cache.pk_no,
+				      keyblock_cache.uid_no,
+				      keyblock_cache.sigstatus,
+				      ret_kb);
+	  if (err)
+	    keyblock_cache_clear ();
+	  if (DBG_CLOCK)
+	    log_clock (err? "keydb_get_keyblock leave (cached, failed)"
+		       : "keydb_get_keyblock leave (cached)");
+	  return err;
+	}
     }
 
   if (hd->found < 0 || hd->found >= hd->used)

commit 219de84df9a8408fffedbb2600f5eb4c441950b6
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Sep 2 10:30:59 2015 +0200

    iobuf: Reduce verbosity of test.
    
    * common/t-iobuf.c (main): Reduce verbosity.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>.

diff --git a/common/t-iobuf.c b/common/t-iobuf.c
index 839798f..99581b9 100644
--- a/common/t-iobuf.c
+++ b/common/t-iobuf.c
@@ -335,11 +335,13 @@ main (int argc, char *argv[])
     assert (rc == 0);
 
     n = iobuf_temp_to_buffer (iobuf, buffer, sizeof (buffer));
+#if 0
     printf ("Got %d bytes\n", n);
     printf ("buffer: `");
     fwrite (buffer, n, 1, stdout);
     fputc ('\'', stdout);
     fputc ('\n', stdout);
+#endif
 
     assert (n == strlen (content) + 2 * (strlen (content2) + 1));
     assert (strcmp (buffer, "0123456789aabbcc") == 0);

commit f2d75ac7dc58f5ea59b231be6b83fea939b43ab8
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Sep 2 10:24:33 2015 +0200

    iobuf: Add the IOBUF_INPUT_TEMP type to improve input temp handling.
    
    * common/iobuf.h (enum iobuf_use): Add new member, IOBUF_INPUT_TEMP.
    * common/iobuf.c (iobuf_temp_with_content): Create the iobuf as an
    IOBUF_INPUT_TEMP, not an IOBUF_INPUT buffer.  Assert that LENGTH ==
    A->D.SIZE.
    (iobuf_push_filter2): If A is an IOBUF_INPUT_TEMP, then make the new
    filter an IOBUF_INPUT filter and set its buffer size to
    IOBUF_BUFFER_SIZE.
    (underflow): If A is an IOBUF_INPUT_TEMP, then just return EOF; don't
    remove already read data.
    (iobuf_seek): If A is an IOBUF_INPUT_TEMP, don't discard the buffered
    data.
    (iobuf_alloc): Allow USE == IOBUF_INPUT_TEMP.
    (pop_filter): Allow USE == IOBUF_INPUT_TEMP.
    (iobuf_peek): Allow USE == IOBUF_INPUT_TEMP.
    (iobuf_writebyte): Fail if USE == IOBUF_INPUT_TEMP.
    (iobuf_write): Fail if USE == IOBUF_INPUT_TEMP.
    (iobuf_writestr): Fail if USE == IOBUF_INPUT_TEMP.
    (iobuf_flush_temp): Fail if USE == IOBUF_INPUT_TEMP.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>.
    
    Introduce a new iobuf type, IOBUF_INPUT_TEMP.  Use this for the iobuf
    created by iobuf_temp_with_content instead of IOBUF_INPUT.  This was
    necessary so that seeking and peeking correctly work on this type of
    iobuf.  In particular, seeking didn't work because we discarded the
    buffered data and peeking didn't work because we discarded data which
    was already read, which made seeking later impossible.

diff --git a/common/iobuf.c b/common/iobuf.c
index a6786b1..795ff11 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -1099,7 +1099,7 @@ iobuf_alloc (int use, size_t bufsize)
   iobuf_t a;
   static int number = 0;
 
-  assert (use == IOBUF_INPUT
+  assert (use == IOBUF_INPUT || use == IOBUF_INPUT_TEMP
 	  || use == IOBUF_OUTPUT || use == IOBUF_OUTPUT_TEMP);
   if (bufsize == 0)
     {
@@ -1220,7 +1220,8 @@ iobuf_temp_with_content (const char *buffer, size_t length)
   iobuf_t a;
   int i;
 
-  a = iobuf_alloc (IOBUF_INPUT, length);
+  a = iobuf_alloc (IOBUF_INPUT_TEMP, length);
+  assert (length == a->d.size);
   /* memcpy (a->d.buf, buffer, length); */
   for (i=0; i < length; i++)
     a->d.buf[i] = buffer[i];
@@ -1619,6 +1620,12 @@ iobuf_push_filter2 (iobuf_t a,
 	 size.  */
       a->d.size = IOBUF_BUFFER_SIZE;
     }
+  else if (a->use == IOBUF_INPUT_TEMP)
+    /* Same idea as above.  */
+    {
+      a->use = IOBUF_INPUT;
+      a->d.size = IOBUF_BUFFER_SIZE;
+    }
 
   /* The new filter (A) gets a new buffer.
 
@@ -1678,7 +1685,7 @@ pop_filter (iobuf_t a, int (*f) (void *opaque, int control,
   if (DBG_IOBUF)
     log_debug ("iobuf-%d.%d: pop '%s'\n",
 	       a->no, a->subno, iobuf_desc (a));
-  if (a->use == IOBUF_OUTPUT_TEMP)
+  if (a->use == IOBUF_INPUT_TEMP || a->use == IOBUF_OUTPUT_TEMP)
     {
       /* This should be the last filter in the pipeline.  */
       assert (! a->chain);
@@ -1765,6 +1772,11 @@ underflow (iobuf_t a, int clear_pending_eof)
 	       (int) a->d.size, (int) (a->d.len - a->d.start),
 	       (int) (a->d.size - (a->d.len - a->d.start)));
 
+  if (a->use == IOBUF_INPUT_TEMP)
+    /* By definition, there isn't more data to read into the
+       buffer.  */
+    return -1;
+
   assert (a->use == IOBUF_INPUT);
 
   /* If there is still some buffered data, then move it to the start
@@ -2056,7 +2068,7 @@ iobuf_peek (iobuf_t a, byte * buf, unsigned buflen)
   int n = 0;
 
   assert (buflen > 0);
-  assert (a->use == IOBUF_INPUT);
+  assert (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP);
 
   if (buflen > a->d.size)
     /* We can't peek more than we can buffer.  */
@@ -2097,7 +2109,7 @@ iobuf_writebyte (iobuf_t a, unsigned int c)
 {
   int rc;
 
-  if (a->use == IOBUF_INPUT)
+  if (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP)
     {
       log_bug ("iobuf_writebyte called on an input pipeline!\n");
       return -1;
@@ -2119,7 +2131,7 @@ iobuf_write (iobuf_t a, const void *buffer, unsigned int buflen)
   const unsigned char *buf = (const unsigned char *)buffer;
   int rc;
 
-  if (a->use == IOBUF_INPUT)
+  if (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP)
     {
       log_bug ("iobuf_write called on an input pipeline!\n");
       return -1;
@@ -2152,7 +2164,7 @@ iobuf_write (iobuf_t a, const void *buffer, unsigned int buflen)
 int
 iobuf_writestr (iobuf_t a, const char *buf)
 {
-  if (a->use == IOBUF_INPUT)
+  if (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP)
     {
       log_bug ("iobuf_writestr called on an input pipeline!\n");
       return -1;
@@ -2200,7 +2212,7 @@ iobuf_temp_to_buffer (iobuf_t a, byte * buffer, size_t buflen)
 void
 iobuf_flush_temp (iobuf_t temp)
 {
-  if (temp->use == IOBUF_INPUT)
+  if (temp->use == IOBUF_INPUT || temp->use == IOBUF_INPUT_TEMP)
     log_bug ("iobuf_writestr called on an input pipeline!\n");
   while (temp->chain)
     pop_filter (temp, temp->filter, NULL);
@@ -2379,10 +2391,9 @@ iobuf_seek (iobuf_t a, off_t newpos)
 	  return -1;
 	}
 #endif
+      /* Discard the buffer it is not a temp stream.  */
+      a->d.len = 0;
     }
-  /* Discard the buffer it is not a temp stream.  */
-  if (a->use != IOBUF_OUTPUT_TEMP)
-    a->d.len = 0;
   a->d.start = 0;
   a->nbytes = 0;
   a->nlimit = 0;
@@ -2409,10 +2420,6 @@ iobuf_seek (iobuf_t a, off_t newpos)
 }
 
 
-
-
-
-
 const char *
 iobuf_get_real_fname (iobuf_t a)
 {
@@ -2430,7 +2437,6 @@ iobuf_get_real_fname (iobuf_t a)
   return NULL;
 }
 
-
 const char *
 iobuf_get_fname (iobuf_t a)
 {
@@ -2462,7 +2468,6 @@ iobuf_set_partial_block_mode (iobuf_t a, size_t len)
 {
   block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx);
 
-  assert (a->use == IOBUF_INPUT || a->use == IOBUF_OUTPUT);
   ctx->use = a->use;
   if (!len)
     {
diff --git a/common/iobuf.h b/common/iobuf.h
index b65ea60..bce6c31 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -124,12 +124,15 @@ enum iobuf_use
     /* Pipeline is in input mode.  The data flows from the end to the
        beginning.  That is, when reading from the pipeline, the first
        filter gets its input from the second filter, etc.  */
-    IOBUF_INPUT=1,
+    IOBUF_INPUT,
+    /* Pipeline is in input mode.  The last filter in the pipeline is
+       a temporary buffer from which the data is "read".  */
+    IOBUF_INPUT_TEMP,
     /* Pipeline is in output mode.  The data flows from the beginning
        to the end.  That is, when writing to the pipeline, the user
        writes to the first filter, which transforms the data and sends
        it to the second filter, etc.  */
-    IOBUF_OUTPUT=2,
+    IOBUF_OUTPUT,
     /* Pipeline is in output mode.  The last filter in the pipeline is
        a temporary buffer that grows as necessary.  */
     IOBUF_OUTPUT_TEMP
@@ -274,7 +277,8 @@ int  iobuf_is_pipe_filename (const char *fname);
    create a new primary source or primary sink, i.e., the last filter
    in the pipeline.
 
-   USE is IOBUF_INPUT, IOBUF_OUTPUT or IOBUF_OUTPUT_TEMP.
+   USE is IOBUF_INPUT, IOBUF_INPUT_TEMP, IOBUF_OUTPUT or
+   IOBUF_OUTPUT_TEMP.
 
    BUFSIZE is the desired internal buffer size (that is, the size of
    the typical read / write request).  */

commit 5ff5e72b9c275fbd978136b1028bbf251af26e57
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Sep 2 09:56:09 2015 +0200

    iobuf: Rename IOBUF_TEMP to IOBUF_OUTPUT_TEMP.
    
    * common/iobuf.h (enum iobuf_use): Rename IOBUF_TEMP to
    IOBUF_OUTPUT_TEMP.  Update users.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>.

diff --git a/common/iobuf.c b/common/iobuf.c
index 35b58ff..a6786b1 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -170,10 +170,10 @@ static int translate_file_handle (int fd, int for_write);
    underlying file; it just causes any data buffered at the filter A
    to be sent to A's filter function.
 
-   If A is a IOBUF_TEMP filter, then this also enlarges the buffer by
-   IOBUF_BUFFER_SIZE.
+   If A is a IOBUF_OUTPUT_TEMP filter, then this also enlarges the
+   buffer by IOBUF_BUFFER_SIZE.
 
-   May only be called on an IOBUF_OUTPUT or IOBUF_TEMP filters.  */
+   May only be called on an IOBUF_OUTPUT or IOBUF_OUTPUT_TEMP filters.  */
 static int filter_flush (iobuf_t a);
 
 
@@ -1099,7 +1099,8 @@ iobuf_alloc (int use, size_t bufsize)
   iobuf_t a;
   static int number = 0;
 
-  assert (use == IOBUF_INPUT || use == IOBUF_OUTPUT || use == IOBUF_TEMP);
+  assert (use == IOBUF_INPUT
+	  || use == IOBUF_OUTPUT || use == IOBUF_OUTPUT_TEMP);
   if (bufsize == 0)
     {
       log_bug ("iobuf_alloc() passed a bufsize of 0!\n");
@@ -1210,7 +1211,7 @@ iobuf_cancel (iobuf_t a)
 iobuf_t
 iobuf_temp (void)
 {
-  return iobuf_alloc (IOBUF_TEMP, IOBUF_BUFFER_SIZE);
+  return iobuf_alloc (IOBUF_OUTPUT_TEMP, IOBUF_BUFFER_SIZE);
 }
 
 iobuf_t
@@ -1274,6 +1275,8 @@ do_open (const char *fname, int special_filenames,
   int print_only = 0;
   int fd;
 
+  assert (use == IOBUF_INPUT || use == IOBUF_OUTPUT);
+
   if (special_filenames
       /* NULL or '-'.  */
       && (!fname || (*fname == '-' && !fname[1])))
@@ -1600,13 +1603,13 @@ iobuf_push_filter2 (iobuf_t a,
   a->filter_ov = NULL;
   a->filter_ov_owner = 0;
   a->filter_eof = 0;
-  if (a->use == IOBUF_TEMP)
+  if (a->use == IOBUF_OUTPUT_TEMP)
     /* A TEMP filter buffers any data sent to it; it does not forward
        any data down the pipeline.  If we add a new filter to the
        pipeline, it shouldn't also buffer data.  It should send it
        downstream to be buffered.  Thus, the correct type for a filter
-       added in front of an IOBUF_TEMP filter is IOBUF_OUPUT, not
-       IOBUF_TEMP.  */
+       added in front of an IOBUF_OUTPUT_TEMP filter is IOBUF_OUPUT, not
+       IOBUF_OUTPUT_TEMP.  */
     {
       a->use = IOBUF_OUTPUT;
 
@@ -1675,6 +1678,12 @@ pop_filter (iobuf_t a, int (*f) (void *opaque, int control,
   if (DBG_IOBUF)
     log_debug ("iobuf-%d.%d: pop '%s'\n",
 	       a->no, a->subno, iobuf_desc (a));
+  if (a->use == IOBUF_OUTPUT_TEMP)
+    {
+      /* This should be the last filter in the pipeline.  */
+      assert (! a->chain);
+      return 0;
+    }
   if (!a->filter)
     {				/* this is simple */
       b = a->chain;
@@ -1904,7 +1913,7 @@ filter_flush (iobuf_t a)
   size_t len;
   int rc;
 
-  if (a->use == IOBUF_TEMP)
+  if (a->use == IOBUF_OUTPUT_TEMP)
     {				/* increase the temp buffer */
       size_t newsize = a->d.size + IOBUF_BUFFER_SIZE;
 
@@ -1940,7 +1949,7 @@ iobuf_readbyte (iobuf_t a)
 {
   int c;
 
-  if (a->use != IOBUF_INPUT)
+  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_OUTPUT_TEMP)
     {
       log_bug ("iobuf_readbyte called on a non-INPUT pipeline!\n");
       return -1;
@@ -1974,12 +1983,11 @@ iobuf_read (iobuf_t a, void *buffer, unsigned int buflen)
   unsigned char *buf = (unsigned char *)buffer;
   int c, n;
 
-  if (a->use != IOBUF_INPUT)
+  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_OUTPUT_TEMP)
     {
       log_bug ("iobuf_read called on a non-INPUT pipeline!\n");
       return -1;
     }
-  assert (a->use == IOBUF_INPUT);
 
   if (a->nlimit)
     {
@@ -2158,8 +2166,8 @@ iobuf_writestr (iobuf_t a, const char *buf)
 int
 iobuf_write_temp (iobuf_t dest, iobuf_t source)
 {
-  assert (source->use == IOBUF_OUTPUT || source->use == IOBUF_TEMP);
-  assert (dest->use == IOBUF_OUTPUT || dest->use == IOBUF_TEMP);
+  assert (source->use == IOBUF_OUTPUT || source->use == IOBUF_OUTPUT_TEMP);
+  assert (dest->use == IOBUF_OUTPUT || dest->use == IOBUF_OUTPUT_TEMP);
 
   iobuf_flush_temp (source);
   return iobuf_write (dest, source->d.buf, source->d.len);
@@ -2346,7 +2354,7 @@ iobuf_seek (iobuf_t a, off_t newpos)
 {
   file_filter_ctx_t *b = NULL;
 
-  if (a->use != IOBUF_TEMP)
+  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_INPUT)
     {
       /* Find the last filter in the pipeline.  */
       for (; a->chain; a = a->chain)
@@ -2372,8 +2380,8 @@ iobuf_seek (iobuf_t a, off_t newpos)
 	}
 #endif
     }
-  /* Discard the buffer unless it is a temp stream.  */
-  if (a->use != IOBUF_TEMP)
+  /* Discard the buffer it is not a temp stream.  */
+  if (a->use != IOBUF_OUTPUT_TEMP)
     a->d.len = 0;
   a->d.start = 0;
   a->nbytes = 0;
diff --git a/common/iobuf.h b/common/iobuf.h
index 36b14b7..b65ea60 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -58,13 +58,14 @@
    in the iobuf_t.
 
    A pipeline can only be used for reading (IOBUF_INPUT) or for
-   writing (IOBUF_OUTPUT / IOBUF_TEMP).  When reading, data flows from
-   the last filter towards the first.  That is, the user calls
-   iobuf_read(), the module reads from the first filter, which gets
-   its input from the second filter, etc.  When writing, data flows
-   from the first filter towards the last.  In this case, when the
-   user calls iobuf_write(), the data is written to the first filter,
-   which writes the transformed data to the second filter, etc.
+   writing (IOBUF_OUTPUT / IOBUF_OUTPUT_TEMP).  When reading, data
+   flows from the last filter towards the first.  That is, the user
+   calls iobuf_read(), the module reads from the first filter, which
+   gets its input from the second filter, etc.  When writing, data
+   flows from the first filter towards the last.  In this case, when
+   the user calls iobuf_write(), the data is written to the first
+   filter, which writes the transformed data to the second filter,
+   etc.
 
    An iobuf_t contains some state about the filter.  For instance, it
    indicates if the filter has already returned EOF (filter_eof) and
@@ -131,7 +132,7 @@ enum iobuf_use
     IOBUF_OUTPUT=2,
     /* Pipeline is in output mode.  The last filter in the pipeline is
        a temporary buffer that grows as necessary.  */
-    IOBUF_TEMP=3
+    IOBUF_OUTPUT_TEMP
   };
 
 
@@ -142,7 +143,7 @@ typedef struct iobuf_struct *IOBUF;  /* Compatibility with gpg 1.4. */
 struct iobuf_struct
 {
   /* The type of filter.  Either IOBUF_INPUT, IOBUF_OUTPUT or
-     IOBUF_TEMP.  */
+     IOBUF_OUTPUT_TEMP.  */
   enum iobuf_use use;
 
   /* nlimit can be changed using iobuf_set_limit.  If non-zero, it is
@@ -273,7 +274,7 @@ int  iobuf_is_pipe_filename (const char *fname);
    create a new primary source or primary sink, i.e., the last filter
    in the pipeline.
 
-   USE is IOBUF_INPUT, IOBUF_OUTPUT or IOBUF_TEMP.
+   USE is IOBUF_INPUT, IOBUF_OUTPUT or IOBUF_OUTPUT_TEMP.
 
    BUFSIZE is the desired internal buffer size (that is, the size of
    the typical read / write request).  */
@@ -437,7 +438,7 @@ int iobuf_print_chain (iobuf_t a);
 void iobuf_set_limit (iobuf_t a, off_t nlimit);
 
 /* Returns the number of bytes that have been read from the pipeline.
-   Note: the result is undefined for IOBUF_OUTPUT and IOBUF_TEMP
+   Note: the result is undefined for IOBUF_OUTPUT and IOBUF_OUTPUT_TEMP
    pipelines!  */
 off_t iobuf_tell (iobuf_t a);
 
@@ -604,6 +605,6 @@ void iobuf_skip_rest (iobuf_t a, unsigned long n, int partial);
 #define iobuf_get_temp_length(a) ( (a)->d.len )
 
 /* Whether the filter uses an in-memory buffer.  */
-#define iobuf_is_temp(a)	 ( (a)->use == IOBUF_TEMP )
+#define iobuf_is_temp(a)	 ( (a)->use == IOBUF_OUTPUT_TEMP )
 
 #endif /*GNUPG_COMMON_IOBUF_H*/

commit 24259d856b6cbdd679035512a8fb7c042de8f02e
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Sep 1 22:17:23 2015 +0200

    iobuf: Use a first-class enum.
    
    * common/iobuf.h (enum iobuf_use): Name the IOBUF_OUTPUT, etc. enum.
    (struct iobuf_struct): Change the field use's type to it.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>.

diff --git a/common/iobuf.h b/common/iobuf.h
index 7157e0f..36b14b7 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -118,7 +118,7 @@ typedef enum
     IOBUF_IOCTL_FSYNC            = 4  /* Uses ptrval.  */
   } iobuf_ioctl_t;
 
-enum
+enum iobuf_use
   {
     /* Pipeline is in input mode.  The data flows from the end to the
        beginning.  That is, when reading from the pipeline, the first
@@ -143,7 +143,7 @@ struct iobuf_struct
 {
   /* The type of filter.  Either IOBUF_INPUT, IOBUF_OUTPUT or
      IOBUF_TEMP.  */
-  int use;
+  enum iobuf_use use;
 
   /* nlimit can be changed using iobuf_set_limit.  If non-zero, it is
      the number of additional bytes that can be read from the filter

commit 8522cdc2264804d0677b7c0a447a0b45cf4195e3
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Sep 1 22:13:45 2015 +0200

    iobuf: Fix test.
    
    * common/t-iobuf.c (content_filter): If there is nothing to read,
    don't forget to set *LEN to 0.
    (main): Fix checks.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>.

diff --git a/common/t-iobuf.c b/common/t-iobuf.c
index ae72fde..839798f 100644
--- a/common/t-iobuf.c
+++ b/common/t-iobuf.c
@@ -111,15 +111,14 @@ content_filter (void *opaque, int control,
       if (toread > remaining)
 	toread = remaining;
 
-      if (toread == 0)
-	return -1;
-
       memcpy (buf, &state->buffer[state->pos], toread);
 
       state->pos += toread;
 
       *len = toread;
 
+      if (toread == 0)
+	return -1;
       return 0;
     }
 
@@ -269,10 +268,8 @@ main (int argc, char *argv[])
   }
 
   {
-    /* - 3 characters plus new line
-       - 4 characters plus new line
-       - 5 characters plus new line
-       - 5 characters, no new line
+    /* - 10 characters, EOF
+       - 17 characters, EOF
      */
     char *content = "abcdefghijklmnopq";
     char *content2 = "0123456789";
@@ -294,7 +291,7 @@ main (int argc, char *argv[])
 	if (c == -1 && lastc == -1)
 	  {
 	    /* printf("Two EOFs in a row.  Done.\n");  */
-	    assert (n == 44);
+	    assert (n == 27);
 	    break;
 	  }
 
@@ -303,7 +300,7 @@ main (int argc, char *argv[])
 	if (c == -1)
 	  {
 	    /* printf("After %d bytes, got EOF.\n", n); */
-	    assert (n == 27 || n == 44);
+	    assert (n == 10 || n == 27);
 	  }
 	else
 	  {

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

Summary of changes:
 common/iobuf.c   | 73 +++++++++++++++++++++++++++++++++-----------------------
 common/iobuf.h   | 37 +++++++++++++++-------------
 common/t-iobuf.c | 17 +++++++------
 g10/keydb.c      | 30 ++++++++++++++---------
 4 files changed, 91 insertions(+), 66 deletions(-)


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




More information about the Gnupg-commits mailing list