summaryrefslogtreecommitdiffstats
path: root/Modules/zipimport.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-18 20:40:59 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-18 20:40:59 (GMT)
commit269aeb7c0d1f092ba0ff20ff44251fd5f4ff87f2 (patch)
treefb0615bc2fa9968c89d884c6fd91bf8212be7404 /Modules/zipimport.c
parentf040d7de94a057f2c26c8b3d140b33273bfcc595 (diff)
downloadcpython-269aeb7c0d1f092ba0ff20ff44251fd5f4ff87f2.zip
cpython-269aeb7c0d1f092ba0ff20ff44251fd5f4ff87f2.tar.gz
cpython-269aeb7c0d1f092ba0ff20ff44251fd5f4ff87f2.tar.bz2
zipimport: pass path size to make_filename()
Don't hardcode path size in make_filename().
Diffstat (limited to 'Modules/zipimport.c')
-rw-r--r--Modules/zipimport.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 4334319..d58d4fe 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -216,7 +216,7 @@ get_subname(char *fullname)
archive (without extension) to the path buffer. Return the
length of the resulting string. */
static int
-make_filename(PyObject *prefix_obj, char *name, char *path)
+make_filename(PyObject *prefix_obj, char *name, char *path, size_t pathsize)
{
size_t len;
char *p;
@@ -228,7 +228,7 @@ make_filename(PyObject *prefix_obj, char *name, char *path)
len = PyBytes_GET_SIZE(prefix);
/* self.prefix + name [+ SEP + "__init__"] + ".py[co]" */
- if (len + strlen(name) + 13 >= MAXPATHLEN) {
+ if (len + strlen(name) + 13 >= pathsize - 1) {
PyErr_SetString(ZipImportError, "path too long");
Py_DECREF(prefix);
return -1;
@@ -263,7 +263,7 @@ get_module_info(ZipImporter *self, char *fullname)
subname = get_subname(fullname);
- len = make_filename(self->prefix, subname, path);
+ len = make_filename(self->prefix, subname, path, sizeof(path));
if (len < 0)
return MI_ERROR;
@@ -507,7 +507,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
}
subname = get_subname(fullname);
- len = make_filename(self->prefix, subname, path);
+ len = make_filename(self->prefix, subname, path, sizeof(path));
if (len < 0)
return NULL;
@@ -1171,7 +1171,7 @@ get_module_code(ZipImporter *self, char *fullname,
subname = get_subname(fullname);
- len = make_filename(self->prefix, subname, path);
+ len = make_filename(self->prefix, subname, path, sizeof(path));
if (len < 0)
return NULL;