Properly read data from stream in pki --pkcs7
This commit is contained in:
@@ -31,13 +31,16 @@ static chunk_t read_from_stream(FILE *stream)
|
|||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
len = fread(buf + total, 1, sizeof(buf) - total, stream);
|
len = fread(buf + total, 1, sizeof(buf) - total, stream);
|
||||||
if (len < 0)
|
if (len < (sizeof(buf) - total))
|
||||||
{
|
{
|
||||||
return chunk_empty;
|
if (ferror(stream))
|
||||||
}
|
{
|
||||||
if (len == 0)
|
return chunk_empty;
|
||||||
{
|
}
|
||||||
return chunk_clone(chunk_create(buf, total));
|
if (feof(stream))
|
||||||
|
{
|
||||||
|
return chunk_clone(chunk_create(buf, total + len));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
total += len;
|
total += len;
|
||||||
if (total == sizeof(buf))
|
if (total == sizeof(buf))
|
||||||
|
|||||||
Reference in New Issue
Block a user