git.iko.soy/typeable/entropy
on main help sign in
Obvious bugs (thanks Felipe!) in prior patch.

NTS: Review this changes as time allows, you are triple-tasking right now.

commita2b4c0b22b28ab27991b180a089876350b29460b authorThomas M. DuBuisson <tommd@galois.com> dateWed 22 Oct 2014, 11:18 (12 years ago) parent3b20128
1 file changed+2−2
System/EntropyNix.hs+2−2
System/EntropyNix.hs+2−2
@@ -78,10 +78,10 @@ hGetEntropy (UseRdRand h) = \n ->
7878
7979fdReadBS :: Fd -> Int -> IO B.ByteString
8080fdReadBS fd n =
81− allocaBytes n $ \buf -> go buf (fromIntegral n)
81+ allocaBytes n $ \buf -> go buf n
8282 where
8383 go buf 0 = B.packCStringLen (castPtr buf, fromIntegral n)
84− go buf cnt | cnt < n = do
84+ go buf cnt | cnt <= n = do
8585 rc <- fdReadBuf fd (plusPtr buf (n - cnt)) (fromIntegral cnt)
8686 case rc of
8787 0 -> ioError (ioeSetErrorString (mkIOError eofErrorType "fdRead" Nothing Nothing) "EOF")