diff --git a/src/Network/Anonymous/Tor/Protocol.hs b/src/Network/Anonymous/Tor/Protocol.hs index 99c6f2e..786d67e 100644 --- a/src/Network/Anonymous/Tor/Protocol.hs +++ b/src/Network/Anonymous/Tor/Protocol.hs @@ -233,7 +233,11 @@ authenticate s = do readCookie :: Maybe FilePath -> IO HS.HexString readCookie Nothing = E.torError (E.mkTorError . E.protocolErrorType $ "No cookie path specified.") - readCookie (Just file) = return . HS.fromBytes =<< BS.readFile file + readCookie (Just file) = do + b <- BS.readFile file + if BS.length b == 32 + then return (HS.fromBytes b) + else E.torError (E.mkTorError . E.protocolErrorType $ "Invalid cookie file specified.") errorF :: Ast.Line -> Maybe E.TorErrorType errorF (Ast.Line 250 _) = Nothing