summaryrefslogtreecommitdiffstats
path: root/common/t-iobuf.c
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@g10code.com>2015-09-01 22:13:45 +0200
committerNeal H. Walfield <neal@g10code.com>2015-09-02 10:07:40 +0200
commit8522cdc2264804d0677b7c0a447a0b45cf4195e3 (patch)
tree8e373cf4370dbbf72c0c98244304ad28262f2a21 /common/t-iobuf.c
parentagent: Protect commit 135b1e3 against misbehaving Libgcrypt. (diff)
downloadgnupg2-8522cdc2264804d0677b7c0a447a0b45cf4195e3.tar.xz
gnupg2-8522cdc2264804d0677b7c0a447a0b45cf4195e3.zip
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@g10code.com>.
Diffstat (limited to '')
-rw-r--r--common/t-iobuf.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/common/t-iobuf.c b/common/t-iobuf.c
index ae72fde90..839798f0c 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
{