bug in unix/System/Posix/Files.hsc
Volker Stolz
stolz@i2.informatik.rwth-aachen.de
Fri, 15 Nov 2002 10:06:41 +0100
In local.glasgow-haskell-users, you wrote:
> readSymbolicLink is broken, it assumes that readlink(2) null terminates its
> result when it doesn't. this causes all sorts of badness.
This should fix it, although all my CVS trees are hosed right now
(now how did I manage to break something in the backup tree?) and I
can't actually test it:
Index: Files.hsc
===================================================================
RCS file: /home/cvs/root/fptools/libraries/unix/System/Posix/Files.hsc,v
retrieving revision 1.3
diff -u -r1.3 Files.hsc
--- Files.hsc 2002/10/08 08:03:02 1.3
+++ Files.hsc 2002/11/15 09:02:03
@@ -352,10 +352,10 @@
readSymbolicLink :: FilePath -> IO FilePath
readSymbolicLink file =
allocaArray0 (#const PATH_MAX) $ \buf -> do
- withCString file $ \s ->
- throwErrnoIfMinus1_ "readSymbolicLink" $
+ withCString file $ \s -> do
+ len <- throwErrnoIfMinus1 "readSymbolicLink" $
c_readlink s buf (#const PATH_MAX)
- peekCString buf
+ peekCStringLen (buf,fromIntegral len)
foreign import ccall unsafe "readlink"
c_readlink :: CString -> CString -> CInt -> IO CInt
--
http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME