pull/unbundle: raise an exception on premature EOF
authormpm@selenic.com
Tue, 20 Sep 2005 10:45:26 -0700
changeset 1280 50553b99a5c9
parent 1279 8ab1c07d4e0b
child 1282 c1a507ba398b
pull/unbundle: raise an exception on premature EOF
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Sep 19 18:24:37 2005 -0700
+++ b/mercurial/localrepo.py	Tue Sep 20 10:45:26 2005 -0700
@@ -956,7 +956,12 @@
             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: