Submitter | phabricator |
---|---|
Date | Oct. 15, 2019, 1:55 p.m. |
Message ID | <differential-rev-PHID-DREV-afxdovcr5afybxjq2adl-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/42356/ |
State | Superseded |
Headers | show |
Comments
This revision is now accepted and ready to land. indygreg added a comment. indygreg accepted this revision. This seems strictly correct, since the `dirs` type should be internal and should be well-formed. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7105/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7105 To: durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel
indygreg added a comment. I dropped this from committed because of discussion on this review and because Windows was not happy with the change: mercurial/cext/dirs.c(75) : error C2275: 'PyObject' : illegal use of this type as an expression c:\dev\python27-64\include\object.h(108) : see declaration of 'PyObject' mercurial/cext/dirs.c(75) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(81) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(81) : warning C4047: '=' : 'int' differs in levels of indirection from 'PyObject *' mercurial/cext/dirs.c(82) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(82) : warning C4047: '!=' : 'int' differs in levels of indirection from 'void *' mercurial/cext/dirs.c(83) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(92) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(92) : warning C4047: '=' : 'int' differs in levels of indirection from 'PyObject *' mercurial/cext/dirs.c(95) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(95) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *' mercurial/cext/dirs.c(98) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(99) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(99) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int' mercurial/cext/dirs.c(99) : warning C4024: 'PyDict_SetItem' : different types for formal and actual parameter 3 mercurial/cext/dirs.c(100) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(100) : error C2065: 'val' : undeclared identifier mercurial/cext/dirs.c(100) : error C2065: 'val' : undeclared identifier error: command 'C:\\Users\\gps\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2 TBH I'm not sure what's going on there. Perhaps a bad byte/newline sequence in the file? `1f04c51d52eadb12bfbb6fba8eca27e742ea88d4` is the node that was dropped. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7105/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7105 To: durin42, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel
> TBH I'm not sure what's going on there. Perhaps a bad byte/newline sequence in the file?
It's a C89 thing. Declarations must come first.
yuja added a comment.
> TBH I'm not sure what's going on there. Perhaps a bad byte/newline sequence in the file?
It's a C89 thing. Declarations must come first.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7105/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7105
To: durin42, #hg-reviewers, indygreg
Cc: yuja, indygreg, mercurial-devel
Patch
diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c --- a/mercurial/cext/dirs.c +++ b/mercurial/cext/dirs.c @@ -52,6 +52,7 @@ { const char *cpath = PyBytes_AS_STRING(path); Py_ssize_t pos = PyBytes_GET_SIZE(path); + Py_ssize_t prev_pos = -1; PyObject *key = NULL; int ret = -1; @@ -64,6 +65,13 @@ * locations, the references are known so these violations should go * unnoticed. */ while ((pos = _finddir(cpath, pos - 1)) != -1) { + if (pos && prev_pos == pos + 1) { + PyErr_SetString( + PyExc_ValueError, + "invalid empty directory name in dirs.c _addpath"); + return -1; + } + prev_pos = pos; PyObject *val; key = PyBytes_FromStringAndSize(cpath, pos);