From 3d82a4af02456ed4732bd00c660261c507a430f2 Mon Sep 17 00:00:00 2001 From: deadwood Date: Sun, 30 Jun 2013 08:10:18 +0000 Subject: [PATCH] arosc.library - fix crash when fseek is used on fopen(directory) If directory is fopened, the file handler is really a lock and calling Flush/Seek on a lock causes a crash. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@47617 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/clib/fseek.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/clib/fseek.c b/compiler/clib/fseek.c index 3b1da320e9..a8d8a918d4 100644 --- a/compiler/clib/fseek.c +++ b/compiler/clib/fseek.c @@ -50,6 +50,9 @@ Not fully compatible with iso fseek, especially in 'ab' and 'a+b' modes + Since it's not possible to use Seek() for directories, this + implementation fails with EISDIR for directory file descriptors. + SEE ALSO fopen(), fwrite() @@ -70,6 +73,12 @@ return -1; } + if (fdesc->fcb->isdir) + { + errno = EISDIR; + return -1; + } + fh = (BPTR)(fdesc->fcb->fh); /* This is buffered IO, flush the buffer before any Seek */ -- 2.11.4.GIT