[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #30920 [Core Tor/Tor]: Detect uint64 overflow in config_parse_units()
#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
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs