mercurial/localrepo.py
changeset 1280 50553b99a5c9
parent 1260 4603eef60237
child 1316 b650bfdfc7ee
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -956,7 +956,12 @@ class localrepository:
             if not d: return ""
             l = struct.unpack(">l", d)[0]
             if l <= 4: return ""
-            return source.read(l - 4)
+            d = source.read(l - 4)
+            if len(d) < l - 4:
+                raise repo.RepoError("premature EOF reading chunk" +
+                                     " (got %d bytes, expected %d)"
+                                     % (len(d), l - 4))
+            return d
 
         def getgroup():
             while 1: