aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/iobuf.c6
-rw-r--r--g10/armor.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/common/iobuf.c b/common/iobuf.c
index 8a128b3f6..769df958d 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2043,6 +2043,8 @@ underflow_target (iobuf_t a, int clear_pending_eof, size_t target)
}
else
{
+ size_t tmplen;
+
/* If no buffered data and drain buffer has been setup, and
* drain buffer is largish, read data directly to drain buffer. */
if (a->d.len == 0
@@ -2056,8 +2058,10 @@ underflow_target (iobuf_t a, int clear_pending_eof, size_t target)
" A->FILTER (%lu bytes, to external drain)\n",
a->no, a->subno, (ulong)len);
+ tmplen = len; /* Used to check for bugs in the filter. */
rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain,
a->e_d.buf, &len);
+ log_assert (len <= tmplen);
a->e_d.used = len;
len = 0;
}
@@ -2067,8 +2071,10 @@ underflow_target (iobuf_t a, int clear_pending_eof, size_t target)
log_debug ("iobuf-%d.%d: underflow: A->FILTER (%lu bytes)\n",
a->no, a->subno, (ulong)len);
+ tmplen = len;
rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain,
&a->d.buf[a->d.len], &len);
+ log_assert (len <= tmplen);
}
}
a->d.len += len;
diff --git a/g10/armor.c b/g10/armor.c
index 036b72772..59a6202aa 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -1312,8 +1312,8 @@ armor_filter( void *opaque, int control,
n = 0;
if( afx->buffer_len ) {
/* Copy the data from AFX->BUFFER to BUF. */
- for(; n < size && afx->buffer_pos < afx->buffer_len; n++ )
- buf[n++] = afx->buffer[afx->buffer_pos++];
+ for(; n < size && afx->buffer_pos < afx->buffer_len;)
+ buf[n++] = afx->buffer[afx->buffer_pos++];
if( afx->buffer_pos >= afx->buffer_len )
afx->buffer_len = 0;
}