revlog: properly detect corrupted revlog in `index_get_length`
Pointed out by Yuya Nishihara.
--- a/mercurial/cext/revlog.c Mon Nov 26 00:15:12 2018 +0100
+++ b/mercurial/cext/revlog.c Mon Nov 26 00:21:09 2018 +0100
@@ -242,7 +242,14 @@
return (int)ret;
} else {
const char *data = index_deref(self, rev);
- return (int)getbe32(data + 8);
+ int tmp = (int)getbe32(data + 8);
+ if (tmp < 0) {
+ PyErr_Format(PyExc_OverflowError,
+ "revlog entry size out of bound (%d)",
+ tmp);
+ return -1;
+ }
+ return tmp;
}
}