changeset 43542 | 5d40317d42b7 |
parent 43233 | ea62d7b06c12 |
child 43702 | 0796e266d26b |
--- a/mercurial/cext/dirs.c Tue Nov 05 22:56:12 2019 -0500 +++ b/mercurial/cext/dirs.c Thu Oct 17 19:29:22 2019 -0400 @@ -66,6 +66,14 @@ while ((pos = _finddir(cpath, pos - 1)) != -1) { PyObject *val; + /* Sniff for trailing slashes, a marker of an invalid input. */ + if (pos > 0 && cpath[pos - 1] == '/') { + PyErr_SetString( + PyExc_ValueError, + "found invalid consecutive slashes in path"); + goto bail; + } + key = PyBytes_FromStringAndSize(cpath, pos); if (key == NULL) goto bail;