Skip to content

Commit

Permalink
fix(OpMsg): cap requestIds at 0x7fffffff
Browse files Browse the repository at this point in the history
Since OpMsg uses buffer write methods, these methods can throw if the buffer
attempts to write a number to large for the space. We now cap the requestId
at 0x7fffffff and loop back around to 0

Fixes NODE-2067
  • Loading branch information
daprahamian committed Aug 13, 2019
1 parent 4abd45b commit c0e87d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/core/connection/msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class Msg {
}

Msg.getRequestId = function() {
return ++_requestId;
_requestId = (_requestId + 1) & 0x7fffffff;
return _requestId;
};

class BinMsg {
Expand Down

0 comments on commit c0e87d5

Please sign in to comment.