From 1c06e0bee160b81f6288309e3df7185a0e3d138b Mon Sep 17 00:00:00 2001 From: Debian Games Team Date: Thu, 12 Jan 2017 16:30:21 +0000 Subject: [PATCH] ad435d95ca4b # HG changeset patch # User unc0rr # Date 1475346425 -10800 # Node ID ad435d95ca4b5fbffb88a440ea28548d6784d8cf # Parent 0b8f2116aa26e68d262fb812e6d441c1a3dec145 - Use sandi instead of dataenc (bugs.debian.org/836686) - Only try to import module from the package being tested (sometimes packages have modules with equal names, so a test for module presence could succeed when you have one package installed instead of another) Gbp-Pq: Name ad435d95ca4b.patch --- cmake_modules/CheckHaskellModuleExists.cmake | 3 +++ gameServer/CMakeLists.txt | 2 +- gameServer/EngineInteraction.hs | 12 ++++++------ gameServer/NetRoutines.hs | 5 +---- gameServer/hedgewars-server.cabal | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmake_modules/CheckHaskellModuleExists.cmake b/cmake_modules/CheckHaskellModuleExists.cmake index 26b6812..42a318a 100644 --- a/cmake_modules/CheckHaskellModuleExists.cmake +++ b/cmake_modules/CheckHaskellModuleExists.cmake @@ -28,6 +28,9 @@ macro(CHECK_HASKELL_MODULE_EXISTS MODULE FUNCTION PARAMCOUNT LIBRARY) "-DMODULE=${MODULE}" "-DFUNCTION=${FUNCTION}" "-DPARAMETERS=${PARAMETERS}" + -hide-all-packages + -package ${LIBRARY} + -package base -cpp -c "${CMAKE_MODULE_PATH}/checkModule.hs" RESULT_VARIABLE COMMAND_RESULT diff --git a/gameServer/CMakeLists.txt b/gameServer/CMakeLists.txt index 46eaa80..43bcf23 100644 --- a/gameServer/CMakeLists.txt +++ b/gameServer/CMakeLists.txt @@ -13,7 +13,7 @@ check_haskell_module_exists("Text.Show.ByteString" putDigit 1 bytestring-show) check_haskell_module_exists("Network.BSD" getHostName 0 network) check_haskell_module_exists("Data.Time" getCurrentTime 0 time) check_haskell_module_exists("Control.Monad.State" fix 1 mtl) -check_haskell_module_exists("Codec.Binary.Base64" encode 1 dataenc) +check_haskell_module_exists("Codec.Binary.Base64" encode 1 sandi) check_haskell_module_exists("System.Log.Logger" warningM 1 hslogger) check_haskell_module_exists("System.Process" createProcess 3 process) check_haskell_module_exists("Data.ByteString.Lazy.UTF8" decode 1 utf8-string) diff --git a/gameServer/EngineInteraction.hs b/gameServer/EngineInteraction.hs index e9684ff..13646b0 100644 --- a/gameServer/EngineInteraction.hs +++ b/gameServer/EngineInteraction.hs @@ -59,7 +59,7 @@ decompressWithoutExceptions = finalise #endif toEngineMsg :: B.ByteString -> B.ByteString -toEngineMsg msg = B.pack $ Base64.encode (fromIntegral (BW.length msg) : BW.unpack msg) +toEngineMsg msg = Base64.encode (fromIntegral (BW.length msg) `BW.cons` msg) {-fromEngineMsg :: B.ByteString -> Maybe B.ByteString @@ -81,15 +81,15 @@ splitMessages = L.unfoldr (\b -> if B.null b then Nothing else Just $ B.splitAt checkNetCmd :: B.ByteString -> (B.ByteString, B.ByteString, Maybe (Maybe B.ByteString)) checkNetCmd msg = check decoded where - decoded = liftM (splitMessages . BW.pack) $ Base64.decode $ B.unpack msg - check Nothing = (B.empty, B.empty, Nothing) - check (Just msgs) = let (a, b) = (filter isLegal msgs, filter isNonEmpty a) in (encode a, encode b, lft a) - encode = B.pack . Base64.encode . BW.unpack . B.concat + decoded = liftM splitMessages $ Base64.decode msg + check (Left _) = (B.empty, B.empty, Nothing) + check (Right msgs) = let (a, b) = (filter isLegal msgs, filter isNonEmpty a) in (encode a, encode b, lft a) + encode = Base64.encode . B.concat isLegal m = (B.length m > 1) && (flip Set.member legalMessages . B.head . B.tail $ m) lft = foldr l Nothing l m n = let m' = B.head $ B.tail m; tst = flip Set.member in if not $ tst timedMessages m' then n - else if '+' /= m' then Just Nothing else Just . Just . B.pack . Base64.encode . BW.unpack $ m + else if '+' /= m' then Just Nothing else Just . Just . Base64.encode $ m isNonEmpty = (/=) '+' . B.head . B.tail legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtgfhbc12345" ++ slotMessages slotMessages = "\128\129\130\131\132\133\134\135\136\137\138" diff --git a/gameServer/NetRoutines.hs b/gameServer/NetRoutines.hs index 10be746..9d0627e 100644 --- a/gameServer/NetRoutines.hs +++ b/gameServer/NetRoutines.hs @@ -25,11 +25,8 @@ import Data.Time import Control.Monad import Data.Unique import qualified Codec.Binary.Base64 as Base64 -import qualified Data.ByteString as BW -import qualified Data.ByteString.Char8 as B import qualified Control.Exception as E import System.Entropy -import Data.Either ----------------------------- import CoreTypes import Utils @@ -48,7 +45,7 @@ acceptLoop servSock chan = E.bracket openHandle closeHandle (forever . f) sendChan' <- newChan uid <- newUnique - salt <- liftM (B.pack . Base64.encode . BW.unpack) $ hGetEntropy ch 18 + salt <- liftM Base64.encode $ hGetEntropy ch 18 let newClient = (ClientInfo diff --git a/gameServer/hedgewars-server.cabal b/gameServer/hedgewars-server.cabal index f36a190..98e45de 100644 --- a/gameServer/hedgewars-server.cabal +++ b/gameServer/hedgewars-server.cabal @@ -26,7 +26,7 @@ Executable hedgewars-server random, time, mtl >= 2, - dataenc, + sandi, hslogger, process, deepseq, -- 2.30.2