X-Git-Url: https://code.delx.au/offlineimap/blobdiff_plain/0f022ec64bede3ad94e5bb2e99cf1ea6ac9d74ef..a7b53cef29e68a8f87028cc9300d822322dd9f36:/src/Network/IMAP/Connection.hs diff --git a/src/Network/IMAP/Connection.hs b/src/Network/IMAP/Connection.hs index ace53e8..998f0b5 100644 --- a/src/Network/IMAP/Connection.hs +++ b/src/Network/IMAP/Connection.hs @@ -39,13 +39,15 @@ newStringConnection = writeBytes = lwriteBytes, closeConn = return ()} where - lreadBytes count = - do (s,sw) <- get - if genericLength s < count - then fail "EOF in input in readBytes" - else do let (r, s') = genericSplitAt count s - put (s', sw) - return r + lreadBytes count + | count < 0 = fail "readBytes: negative count" + | otherwise = + do (s,sw) <- get + if genericLength s < count + then fail "EOF in input in readBytes" + else do let (r, s') = genericSplitAt count s + put (s', sw) + return r lreadLine = do (s, sw) <- get let (line, remainder) = spanList (\x -> "\r\n" /= take 2 x) s