diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-28 12:48:24 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-28 12:48:24 -0400 |
commit | b0aa14ea3b12ab0559793bfb46df4625d7792bd4 (patch) | |
tree | 5abac8706a3c440c0598a57d4c4de8d677a44af1 /HTTP | |
parent | bb9d3ea8598a0b48e9d773df24ff58856cbb9aa0 (diff) | |
download | keysafe-b0aa14ea3b12ab0559793bfb46df4625d7792bd4.tar.gz |
http: refuse to store object of unexpected size
Diffstat (limited to 'HTTP')
-rw-r--r-- | HTTP/Server.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/HTTP/Server.hs b/HTTP/Server.hs index cce91cd..a26cd5e 100644 --- a/HTTP/Server.hs +++ b/HTTP/Server.hs @@ -10,6 +10,7 @@ module HTTP.Server (runServer) where import HTTP import Types import Types.Storage +import Tunables import Storage.Local import Serialization () import Servant @@ -65,9 +66,12 @@ getObject st i _pow = do putObject :: ServerState -> StorableObjectIdent -> Maybe ProofOfWork -> StorableObject -> Handler (ProofOfWorkRequirement StoreResult) putObject st i _pow o = do - r <- liftIO $ storeShare serverStorage i (Share dummyShareNum o) - liftIO $ requestObscure st - return (Result r) + if validObjectsize o + then do + r <- liftIO $ storeShare serverStorage i (Share dummyShareNum o) + liftIO $ requestObscure st + return (Result r) + else throwError err413 -- Request Entity Too Large countObjects :: ServerState -> Maybe ProofOfWork -> Handler (ProofOfWorkRequirement CountResult) countObjects _st _pow = liftIO $ Result <$> countShares serverStorage |