summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-04-20 06:56:05 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-04-20 06:56:05 (GMT)
commit449b24ebe9db3265657152ea4edb60cde4a5136b (patch)
tree9a1b55d39809d7e52effec3ef7b5f612ada29c9c /Modules
parent0d21b1ed54a9c6133ca4b65779647b6d6dde2960 (diff)
downloadcpython-449b24ebe9db3265657152ea4edb60cde4a5136b.zip
cpython-449b24ebe9db3265657152ea4edb60cde4a5136b.tar.gz
cpython-449b24ebe9db3265657152ea4edb60cde4a5136b.tar.bz2
Address issues brought up by MvL on python-checkins.
I tested this with valgrind on amd64. The man pages I found for diff architectures are inconsistent on this. I'm not entirely sure this change is correct for all architectures either. Perhaps we should just over-allocate and not worry about it?
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4b5842e..b51ba5d 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6809,7 +6809,7 @@ posix_confstr(PyObject *self, PyObject *args)
{
PyObject *result = NULL;
int name;
- char buffer[64];
+ char buffer[256];
if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
int len;
@@ -6827,12 +6827,12 @@ posix_confstr(PyObject *self, PyObject *args)
}
else {
if ((unsigned int)len >= sizeof(buffer)) {
- result = PyString_FromStringAndSize(NULL, len+1);
+ result = PyString_FromStringAndSize(NULL, len-1);
if (result != NULL)
- confstr(name, PyString_AS_STRING(result), len+1);
+ confstr(name, PyString_AS_STRING(result), len);
}
else
- result = PyString_FromString(buffer);
+ result = PyString_FromStringAndSize(buffer, len-1);
}
}
return result;