diff options
author | ngie <ngie@FreeBSD.org> | 2015-05-18 10:45:18 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-05-18 10:45:18 +0000 |
commit | 4fde1f4b3850815eb902587349f98dc5612e62f4 (patch) | |
tree | d8875118841419463ad418f56ec645695a9594e4 /lib/libmd | |
parent | 6060820399692402d5e3a9d5dc89f5c78b346db1 (diff) | |
download | FreeBSD-src-4fde1f4b3850815eb902587349f98dc5612e62f4.zip FreeBSD-src-4fde1f4b3850815eb902587349f98dc5612e62f4.tar.gz |
MFC r281928:
Avoid an infinite loop by ensuring that the amount of bytes read is greater
than 0 in MDXFileChunk when calculating the checksum
This edgecase can be triggered if the file is truncated while the checksum
is being calculated (i.e. the EOF is reached)
Differential Revision: https://reviews.freebsd.org/D2351 (patch by darius)
PR: 196694
Reviewed by: delphij, ngie
Submitted by: Daniel O'Connor <darius@dons.net.au>
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'lib/libmd')
-rw-r--r-- | lib/libmd/mdXhl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c index e69e5e5..2954548 100644 --- a/lib/libmd/mdXhl.c +++ b/lib/libmd/mdXhl.c @@ -74,7 +74,7 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len) i = read(f, buffer, sizeof(buffer)); else i = read(f, buffer, n); - if (i < 0) + if (i <= 0) break; MDXUpdate(&ctx, buffer, i); n -= i; |