Skip to content
Snippets Groups Projects
Forked from The Tor Project / Core / Tor
Source project has a limited visibility.
  • José M. Guisado's avatar
    42ba3997
    Check memunit parsing for overflow in confparse · 42ba3997
    José M. Guisado authored
    
    Before, when parsing memunits, if overflow occured it failed silently.
    Use nowrap u64 math to detect overflow, compare to INT64_MAX and if
    greater tell user and fail accordingly.
    
    15000000.5 TB fails double check as it a greater floating number than
    (double)INT64_MAX
    
    8388608.1 TB passes double check because it falls in the same value as
    (double)INT64_MAX (which is 2^63), but will fail the int check because
    (uint64_t)d, which is 2^63, is strictly greater than 2^63-1 (INT64_MAX).
    
    Fixes #30920
    Signed-off-by: default avatarJosé M. Guisado <guigom@riseup.net>
    42ba3997
    History
    Check memunit parsing for overflow in confparse
    José M. Guisado authored
    
    Before, when parsing memunits, if overflow occured it failed silently.
    Use nowrap u64 math to detect overflow, compare to INT64_MAX and if
    greater tell user and fail accordingly.
    
    15000000.5 TB fails double check as it a greater floating number than
    (double)INT64_MAX
    
    8388608.1 TB passes double check because it falls in the same value as
    (double)INT64_MAX (which is 2^63), but will fail the int check because
    (uint64_t)d, which is 2^63, is strictly greater than 2^63-1 (INT64_MAX).
    
    Fixes #30920
    Signed-off-by: default avatarJosé M. Guisado <guigom@riseup.net>