on master help sign in
Add warning about space-usage on the Fixed instance
commit7e1881b73c5fbc0b26ff6f90f60e6016af19c49e authorBas van Dijk <v.dijk.bas@gmail.com> dateWed 14 May 2014, 00:38 (12 years ago) parentbe4d0de
1 file changed+4
Data/Aeson/Types/Instances.hs+4
Data/Aeson/Types/Instances.hs+4
@@ -206,6 +206,10 @@ instance HasResolution a => ToJSON (Fixed a) where
206206 toJSON = Number . realToFrac
207207 {-# INLINE toJSON #-}
208208
209+-- | /WARNING:/ Only parse fixed-precision numbers from trusted input
210+-- since an attacker could easily fill up the memory of the target
211+-- system by specifying a scientific number with a big exponent like
212+-- @1e1000000000@.
209213instance HasResolution a => FromJSON (Fixed a) where
210214 parseJSON = withScientific "Fixed" $ pure . realToFrac
211215 {-# INLINE parseJSON #-}