[tor-bugs] #30920 [Core Tor/Tor]: Detect uint64 overflow in config_parse_units()

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Jun 20 08:57:08 UTC 2019


#30920: Detect uint64 overflow in config_parse_units()
---------------------------+------------------------------------
 Reporter:  nickm          |          Owner:  (none)
     Type:  defect         |         Status:  new
 Priority:  Low            |      Milestone:  Tor: 0.4.2.x-final
Component:  Core Tor/Tor   |        Version:
 Severity:  Minor          |     Resolution:
 Keywords:  easy overflow  |  Actual Points:
Parent ID:                 |         Points:
 Reviewer:                 |        Sponsor:
---------------------------+------------------------------------

Comment (by guigom):

 I would like to volunteer on this one once #30864 is merged, if possible.

 Here is a code snippet for the overflow check multiplication. (Assuming
 `a`  and `b` values are correct)

 {{{
 uint64_t
 tor_mul_u64_nowrap(uint64_t a, uint64_t b)
 {
   if (PREDICT_UNLIKELY(UINT64_MAX / a < b)) {
    return UINT64_MAX;
   } else {
     return a*b;
   }
 }
 }}}

 Adding the function header in `muldiv.h` too.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/30920#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list