common/iobuf.c: Flush the pipeline in iobuf_temp_to_buffer.

* common/iobuf.c (iobuf_temp_to_buffer): Flush each filter in the
pipeline and copy the data from the last (not the first) filter's
internal buffer.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
This commit is contained in:
Neal H. Walfield 2015-08-14 13:19:22 +02:00
parent 15ae99f887
commit 616181f3c7
1 changed files with 13 additions and 1 deletions

View File

@ -2123,8 +2123,20 @@ iobuf_write_temp (iobuf_t a, iobuf_t temp)
size_t
iobuf_temp_to_buffer (iobuf_t a, byte * buffer, size_t buflen)
{
size_t n = a->d.len;
size_t n;
while (1)
{
int rc = filter_flush (a);
if (rc)
log_bug ("Flushing iobuf %d.%d (%s) from iobuf_temp_to_buffer failed. Ignoring.\n",
a->no, a->subno, iobuf_desc (a));
if (! a->chain)
break;
a = a->chain;
}
n = a->d.len;
if (n > buflen)
n = buflen;
memcpy (buffer, a->d.buf, n);