From: sof Date: Mon, 24 Nov 1997 21:21:13 +0000 (+0000) Subject: [project @ 1997-11-24 21:21:13 by sof] X-Git-Tag: Approx_2487_patches~1248 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=11db4c500b5811fb621c0d3d3b584d8d4eb579be;p=ghc-hetmet.git [project @ 1997-11-24 21:21:13 by sof] If possible, catch error when opening files for writing to a dangling symlink --- diff --git a/ghc/lib/cbits/openFile.lc b/ghc/lib/cbits/openFile.lc index 73ebe24..4b92aca 100644 --- a/ghc/lib/cbits/openFile.lc +++ b/ghc/lib/cbits/openFile.lc @@ -67,7 +67,15 @@ StgByteArray how; ghc_errtype = ERR_NOSUCHTHING; ghc_errstr = "file does not exist"; return NULL; - } + } else { + /* If it is a dangling symlink, break off now, too. */ + struct stat st; + if ( lstat(file,&st) == 0) { + ghc_errtype = ERR_NOSUCHTHING; + ghc_errstr = "dangling symlink"; + return NULL; + } + } /* Now try to create it */ while ((fd = open(file, oflags | O_CREAT | O_EXCL, 0666)) < 0) { if (errno == EEXIST) {