From 6ca4390c8e4b6b206731210fe9e9c30d02ab23f2 Mon Sep 17 00:00:00 2001 From: leitner Date: Sat, 14 Nov 2020 17:09:49 +0000 Subject: [PATCH] also advance cur if upstream is a bytestream or an iobuf --- buffer/prs_readblob.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/buffer/prs_readblob.c b/buffer/prs_readblob.c index 7891c4f..059d0e7 100644 --- a/buffer/prs_readblob.c +++ b/buffer/prs_readblob.c @@ -19,7 +19,13 @@ ssize_t prs_readblob(struct bytestream* bs,unsigned char* dest,size_t destlen) { break; case IOBUF: - buffer_get(bs->u.b, (char*)dest, destlen); + r=buffer_get(bs->u.b, (char*)dest, destlen); + if (r != (ssize_t)destlen) { + bs->cur = 1; // set bytestream to error state + bs->max = 0; + return -1; + } + bs->cur += r; break; case BSTREAM: @@ -30,6 +36,7 @@ ssize_t prs_readblob(struct bytestream* bs,unsigned char* dest,size_t destlen) { bs->max = 0; return -1; } + bs->cur += r; break; }