on master help sign in
Add warning about space-usage on the Fixed instance
commitb9a2928906fcb7b36adb87b03e1afb099e708b2d authorBas van Dijk <v.dijk.bas@gmail.com> dateWed 14 May 2014, 00:38 (12 years ago) parent96c4418
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 #-}