diff options
| -rw-r--r-- | debian/changelog | 3 | ||||
| -rw-r--r-- | python/tarfile.cc | 14 |
2 files changed, 13 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog index 87202817..f766ef24 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - Fix some threading issues (add some missing PyCbObj_BEGIN_ALLOW_THREADS) * python/acquire-item.cc: - Support items without an owner set. + * python/tarfile.cc: + - When extracting, only allocate a new buffer if the old one was too small. + - Do not segfault if TarFile.go() is called without a member name. -- Julian Andres Klode <jak@debian.org> Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/tarfile.cc b/python/tarfile.cc index 9c3797fb..c1e5f48d 100644 --- a/python/tarfile.cc +++ b/python/tarfile.cc @@ -49,6 +49,8 @@ public: bool error; // Place where the copy of the data is stored. char *copy; + // The size of the copy + size_t copy_size; virtual bool DoItem(Item &Itm,int &Fd); virtual bool FinishedFile(Item &Itm,int Fd); @@ -72,8 +74,12 @@ public: bool PyDirStream::DoItem(Item &Itm, int &Fd) { if (!member || strcmp(Itm.Name, member) == 0) { - delete[] copy; - copy = new char[Itm.Size]; + // Allocate a new buffer if the old one is too small. + if (copy == NULL || copy_size < Itm.Size) { + delete[] copy; + copy = new char[Itm.Size]; + copy_size = Itm.Size; + } Fd = -2; } return true; @@ -91,7 +97,7 @@ bool PyDirStream::FinishedFile(Item &Itm,int Fd) if (member && strcmp(Itm.Name, member) != 0) // Skip non-matching Items, if a specific one is requested. return true; - + // Clear the old objects and create new ones. Py_XDECREF(py_member); Py_XDECREF(py_data); @@ -366,7 +372,7 @@ static PyObject *tarfile_go(PyObject *self, PyObject *args) char *member = 0; if (PyArg_ParseTuple(args,"O|s",&callback,&member) == 0) return 0; - if (strcmp(member, "") == 0) + if (member && strcmp(member, "") == 0) member = 0; pkgDirStream Extract; PyDirStream stream(callback, member); |
