summaryrefslogtreecommitdiffstats
path: root/lib/libmd
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-04-24 11:03:47 +0000
committerngie <ngie@FreeBSD.org>2015-04-24 11:03:47 +0000
commit2aab358f3c44ecc476d08f4e091b48069782b026 (patch)
tree21d03226aa0ddc37beb491d10bd2fa794376c011 /lib/libmd
parentb4f9c4540d0b85c6bb35e6feb7bbde82d86b5bff (diff)
downloadFreeBSD-src-2aab358f3c44ecc476d08f4e091b48069782b026.zip
FreeBSD-src-2aab358f3c44ecc476d08f4e091b48069782b026.tar.gz
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.c2
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;
OpenPOWER on IntegriCloud