Kaydet (Commit) 449b24eb authored tarafından Neal Norwitz's avatar Neal Norwitz

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?
üst 0d21b1ed
...@@ -6809,7 +6809,7 @@ posix_confstr(PyObject *self, PyObject *args) ...@@ -6809,7 +6809,7 @@ posix_confstr(PyObject *self, PyObject *args)
{ {
PyObject *result = NULL; PyObject *result = NULL;
int name; int name;
char buffer[64]; char buffer[256];
if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) { if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
int len; int len;
...@@ -6827,12 +6827,12 @@ posix_confstr(PyObject *self, PyObject *args) ...@@ -6827,12 +6827,12 @@ posix_confstr(PyObject *self, PyObject *args)
} }
else { else {
if ((unsigned int)len >= sizeof(buffer)) { if ((unsigned int)len >= sizeof(buffer)) {
result = PyString_FromStringAndSize(NULL, len+1); result = PyString_FromStringAndSize(NULL, len-1);
if (result != NULL) if (result != NULL)
confstr(name, PyString_AS_STRING(result), len+1); confstr(name, PyString_AS_STRING(result), len);
} }
else else
result = PyString_FromString(buffer); result = PyString_FromStringAndSize(buffer, len-1);
} }
} }
return result; return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment