[PATCH STABLE] parsers: fix width of datalen variable in fm1readmarkers

Yuya Nishihara yuya at tcha.org
Sat Nov 7 10:59:54 UTC 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1446885800 -32400
#      Sat Nov 07 17:43:20 2015 +0900
# Branch stable
# Node ID 70776f5ecbcd42f94cbe2d3c81f858b5bff8e466
# Parent  10a1a4b3e775d6024a82937df6bcc4188a315124
parsers: fix width of datalen variable in fm1readmarkers

Because parsers.c does not define PY_SSIZE_T_CLEAN, "s#" format requires
(const char*, int), not (const char*, Py_ssize_t).

https://docs.python.org/2/c-api/arg.html

This error had no problem before 042344313939, where datalen wasn't used.
But now fm1readmarkers() fails with "overflow in obsstore" on Python 2.6.9
(amd64) because upper bits of datalen seem to be filled with 1, making it
a negative integer.

This problem seems not visible on our Python 2.7 environment because upper
bits happen to be filled with 0.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -2692,7 +2692,7 @@ bail:
 
 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) {
 	const char *data, *dataend;
-	Py_ssize_t datalen;
+	int datalen;
 	Py_ssize_t offset, stop;
 	PyObject *markers = NULL;
 


More information about the Mercurial-devel mailing list