From: Michael Tremer Date: Wed, 22 Mar 2023 10:35:51 +0000 (+0000) Subject: _pakfire: Fix potential SEGV when accesing File attributes X-Git-Tag: 0.9.29~224 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9bac0a75cb31f9f2cebad8cd8229baa6815a2506;p=pakfire.git _pakfire: Fix potential SEGV when accesing File attributes Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/file.c b/src/_pakfire/file.c index 371708923..100a4e515 100644 --- a/src/_pakfire/file.c +++ b/src/_pakfire/file.c @@ -75,6 +75,8 @@ static PyObject* File_repr(FileObject* self) { static PyObject* File_get_path(FileObject* self) { const char* path = pakfire_file_get_path(self->file); + if (!path) + Py_RETURN_NONE; return PyUnicode_FromString(path); } @@ -111,6 +113,8 @@ static PyObject* File_get_type(FileObject* self) { static PyObject* File_get_uname(FileObject* self) { const char* uname = pakfire_file_get_uname(self->file); + if (!uname) + Py_RETURN_NONE; return PyUnicode_FromString(uname); } @@ -126,6 +130,8 @@ static int File_set_uname(FileObject* self, PyObject* value) { static PyObject* File_get_gname(FileObject* self) { const char* gname = pakfire_file_get_gname(self->file); + if (!gname) + Py_RETURN_NONE; return PyUnicode_FromString(gname); } @@ -236,6 +242,8 @@ static PyObject* File_digest(FileObject* self, PyObject* args) { static PyObject* File_get_mimetype(FileObject* self) { const char* mimetype = pakfire_file_get_mimetype(self->file); + if (!mimetype) + Py_RETURN_NONE; return PyUnicode_FromString(mimetype); }