Have makedirs operate on abspaths
clean() wont work with paths that use .. to go to levels above the root of the passed in path.
This commit is contained in:
parent
05f0839add
commit
4e7418f2f1
2 changed files with 7 additions and 7 deletions
|
|
@ -654,10 +654,9 @@ abspath(PyObject *self UNUSED, PyObject *path) {
|
|||
|
||||
static PyObject*
|
||||
py_makedirs(PyObject *self UNUSED, PyObject *args) {
|
||||
int mode = 0755; const char *p; Py_ssize_t sz;
|
||||
if (!PyArg_ParseTuple(args, "s#|i", &p, &sz, &mode)) return NULL;
|
||||
RAII_PyObject(b, PyBytes_FromStringAndSize(p, sz));
|
||||
if (!makedirs(PyBytes_AS_STRING(b), mode)) { PyErr_SetFromErrno(PyExc_OSError); return NULL; }
|
||||
int mode = 0755; const char *p;
|
||||
if (!PyArg_ParseTuple(args, "s|i", &p, &mode)) return NULL;
|
||||
if (!makedirs(p, mode)) { PyErr_SetFromErrno(PyExc_OSError); return NULL; }
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,10 +145,11 @@ makedirs_cleaned(char *path, int mode, struct stat *buffer) {
|
|||
}
|
||||
|
||||
static bool
|
||||
makedirs(char *path /* path is modified by this function */, int mode) {
|
||||
makedirs(const char *path, int mode) {
|
||||
struct stat buffer;
|
||||
clean_path(path);
|
||||
return makedirs_cleaned(path, mode, &buffer);
|
||||
char pbuf[PATH_MAX];
|
||||
lexical_absolute_path(path, pbuf, sizeof(pbuf));
|
||||
return makedirs_cleaned(pbuf, mode, &buffer);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
Loading…
Reference in a new issue