Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7bc80fc

Browse files
committed
Check return value of fstat() in _PyImport_GetDynLoadFunc()
CID 486250
2 parents 2894073 + 27c4c3e commit 7bc80fc

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Python/dynload_shlib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
8181
if (fp != NULL) {
8282
int i;
8383
struct stat statb;
84-
fstat(fileno(fp), &statb);
84+
if (fstat(fileno(fp), &statb) == -1) {
85+
return PyErr_SetFromErrno(PyExc_IOError);
86+
}
8587
for (i = 0; i < nhandles; i++) {
8688
if (statb.st_dev == handles[i].dev &&
8789
statb.st_ino == handles[i].ino) {

0 commit comments

Comments
 (0)