Skip to content

Commit

Permalink
Do not adjust delay when exponent is out of bounds
Browse files Browse the repository at this point in the history
Summary: as title

Reviewed By: silver23arrow, kvtsoy

Differential Revision: D52737239

fbshipit-source-id: 9a9d37dc0cb11f009e3429dede8325b6690b3b46
  • Loading branch information
Luca Niccolini authored and facebook-github-bot committed Jan 13, 2024
1 parent d12dfb5 commit c276e9b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions quic/codec/Decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ uint64_t convertEncodedDurationToMicroseconds(
uint64_t delay) {
// ackDelayExponentToUse is guaranteed to be less than the size of uint64_t
uint64_t delayOverflowMask = 0xFFFFFFFFFFFFFFFF;
uint8_t leftShift = (sizeof(delay) * 8 - exponentToUse);
DCHECK_LT(leftShift, sizeof(delayOverflowMask) * 8);

constexpr uint8_t delayValWidth = sizeof(delay) * 8;
if (exponentToUse == 0 || exponentToUse >= delayValWidth) {
return delay;
}
uint8_t leftShift = (delayValWidth - exponentToUse);
delayOverflowMask = delayOverflowMask << leftShift;
if ((delay & delayOverflowMask) != 0) {
throw QuicTransportException(
Expand Down

0 comments on commit c276e9b

Please sign in to comment.