From 9e3bfcc72461b19d9e138a3e24d04f508895bff7 Mon Sep 17 00:00:00 2001 From: ngie Date: Mon, 18 May 2015 10:46:51 +0000 Subject: [PATCH] MFstable/10 r283054: 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 Sponsored by: EMC / Isilon Storage Division git-svn-id: svn://svn.freebsd.org/base/stable/9@283055 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libmd/mdXhl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c index e69e5e5fa..295454819 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; -- 2.45.0