aboutsummaryrefslogtreecommitdiffstats
path: root/src/pki/commands/pkcs7.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-01-24 18:43:10 +0100
committerTobias Brunner <tobias@strongswan.org>2013-01-24 19:13:41 +0100
commit4cd3fb788d0e0fe27f5f6fffe353d1792e6c6e08 (patch)
tree61fe7c8ef05f92c5ffd0ed8b77d4cf87b34c2e8b /src/pki/commands/pkcs7.c
parent27a814b527d678b9f07c0ccc610fa526bac3ad91 (diff)
downloadstrongswan-4cd3fb788d0e0fe27f5f6fffe353d1792e6c6e08.tar.bz2
strongswan-4cd3fb788d0e0fe27f5f6fffe353d1792e6c6e08.tar.xz
Properly read data from stream in pki --pkcs7
Diffstat (limited to 'src/pki/commands/pkcs7.c')
-rw-r--r--src/pki/commands/pkcs7.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/pki/commands/pkcs7.c b/src/pki/commands/pkcs7.c
index 9f167d376..790656c62 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))