Mercurial > hg-stable
changeset 16679:2950d186a927 stable
parsers: strictly check for 20-byte hashes where they're required
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Sat, 12 May 2012 20:25:33 +0200 |
parents | 48b1674ac1e7 |
children | d0e419b0f7de |
files | mercurial/localrepo.py mercurial/parsers.c |
diffstat | 2 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sat May 12 22:12:54 2012 +0200 +++ b/mercurial/localrepo.py Sat May 12 20:25:33 2012 +0200 @@ -404,7 +404,7 @@ # ignore tags to unknown nodes self.changelog.rev(v) t[k] = v - except error.LookupError: + except (error.LookupError, ValueError): pass return t
--- a/mercurial/parsers.c Sat May 12 22:12:54 2012 +0200 +++ b/mercurial/parsers.c Sat May 12 20:25:33 2012 +0200 @@ -753,7 +753,7 @@ if (PyInt_Check(value)) return index_get(self, PyInt_AS_LONG(value)); - if (PyString_AsStringAndSize(value, &node, &nodelen) == -1) + if (node_check(value, &node, &nodelen) == -1) return NULL; rev = index_find_node(self, node, nodelen); if (rev >= -1) @@ -765,12 +765,15 @@ static PyObject *index_m_get(indexObject *self, PyObject *args) { + Py_ssize_t nodelen; + PyObject *val; char *node; - int nodelen, rev; + int rev; - if (!PyArg_ParseTuple(args, "s#", &node, &nodelen)) + if (!PyArg_ParseTuple(args, "O", &val)) return NULL; - + if (node_check(val, &node, &nodelen) == -1) + return NULL; rev = index_find_node(self, node, nodelen); if (rev == -3) return NULL; @@ -789,11 +792,8 @@ return rev >= -1 && rev < index_length(self); } - if (!PyString_Check(value)) - return 0; - - node = PyString_AS_STRING(value); - nodelen = PyString_GET_SIZE(value); + if (node_check(value, &node, &nodelen) == -1) + return -1; switch (index_find_node(self, node, nodelen)) { case -3: