all repos — mgba @ 2dc729f17a45a4699a099a219ee18124904f94fa

mGBA Game Boy Advance Emulator

VFS: VFileFromFD should not open directories
Jeffrey Pfau jeffrey@endrift.com
Sat, 09 Jul 2016 15:19:31 -0700
commit

2dc729f17a45a4699a099a219ee18124904f94fa

parent

4e4a266d5307f1686f61ab251beb00bca69fb110

2 files changed, 7 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -31,6 +31,7 @@ - ARM7: Fix setting spsr privilege bits when spsr is empty

- GBA BIOS: Fix ArcTan2 accuracy and boundary conditions - SDL: Fix sporadic crash when deinitializing audio - GBA Audio: Reset audio FIFO DMA if an invalid destination is set + - VFS: VFileFromFD should not open directories Misc: - GBA: Slightly optimize GBAProcessEvents - Qt: Add preset for DualShock 4
M src/util/vfs/vfs-fd.csrc/util/vfs/vfs-fd.c

@@ -52,6 +52,12 @@ if (fd < 0) {

return 0; } + struct stat stat; + if (fstat(fd, &stat) < 0 || S_ISDIR(stat.st_mode)) { + close(fd); + return 0; + } + struct VFileFD* vfd = malloc(sizeof(struct VFileFD)); if (!vfd) { return 0;