mercurial/parsers.c
changeset 10449 7c8266c1d15a
parent 10282 08a0f04b56bd
child 11361 3de3d670d2b6
--- a/mercurial/parsers.c	Sat Feb 13 22:10:31 2010 +0100
+++ b/mercurial/parsers.c	Sat Feb 13 17:37:44 2010 -0600
@@ -194,7 +194,7 @@
 		mtime = ntohl(*(uint32_t *)(decode + 8));
 		flen = ntohl(*(uint32_t *)(decode + 12));
 		cur += 17;
-		if (flen > end - cur) {
+		if (cur + flen > end || cur + flen < cur) {
 			PyErr_SetString(PyExc_ValueError, "overflow in dirstate");
 			goto quit;
 		}
@@ -332,7 +332,7 @@
 
 		n++;
 		step = 64 + (inlined ? comp_len : 0);
-		if (end - data < step)
+		if (data + step > end || data + step < data)
 			break;
 		data += step;
 	}