X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=blobdiff_plain;f=src%2Fpki%2Fcommands%2Fpkcs7.c;h=790656c62bef76623f74123c881d56bef817f772;hp=9f167d3768fe1b11d0a600e2edfe9fdc804b8055;hb=4cd3fb788d0e0fe27f5f6fffe353d1792e6c6e08;hpb=27a814b527d678b9f07c0ccc610fa526bac3ad91 diff --git a/src/pki/commands/pkcs7.c b/src/pki/commands/pkcs7.c index 9f167d3..790656c 100644 --- a/src/pki/commands/pkcs7.c +++ b/src/pki/commands/pkcs7.c @@ -31,13 +31,16 @@ static chunk_t read_from_stream(FILE *stream) while (TRUE) { len = fread(buf + total, 1, sizeof(buf) - total, stream); - if (len < 0) + if (len < (sizeof(buf) - total)) { - return chunk_empty; - } - if (len == 0) - { - return chunk_clone(chunk_create(buf, total)); + if (ferror(stream)) + { + return chunk_empty; + } + if (feof(stream)) + { + return chunk_clone(chunk_create(buf, total + len)); + } } total += len; if (total == sizeof(buf))