[PATCH] revlog: don't try to partialmatch strings those length > 40 (issue3570)
Alexander Drozdov
al.drozdov at gmail.com
Thu Aug 2 16:00:41 UTC 2012
# HG changeset patch
# User sorcerer
# Date 1343920245 -14400
# Node ID b9520c3436fa42894238569e2b5edecdf286bc09
# Parent 23b247234454c945ff0b907dd6195a385c134468
revlog: don't try to partialmatch strings those length > 40
_partialmatch() does prefix matching against nodes. String passed
to _partialmetch() actualy may be any string, not prefix only.
For example,
"e410be8603932e46a51298748a4b874739037fad or 300" is a good
argument for _partialmatch().
When _partialmatch() searches using radix tree, index_partialmatch()
C function shouldn't try to match too long strings.
diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1084,8 +1084,10 @@
return NULL;
}
- if (nodelen > 40)
- nodelen = 40;
+ if (nodelen > 40) {
+ PyErr_SetString(PyExc_ValueError, "key too long");
+ return NULL;
+ }
for (i = 0; i < nodelen; i++)
hexdigit(node, i);
More information about the Mercurial-devel
mailing list