Skip to content

Commit

Permalink
try to prevent negatives here
Browse files Browse the repository at this point in the history
Signed-off-by: Jersey <wgyt735yt@gmail.com>
  • Loading branch information
williamhorning committed Mar 23, 2024
1 parent 6d461d9 commit 1c553a7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/protocol/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export class WireProtocol {
throw new MongoDriverError("Invalid response header");
}
const header = parseHeader(headerBuffer);
let bodyBytes = header.messageLength - 16;
if (bodyBytes < 0) bodyBytes = 0;
const bodyBuffer = await this.read_socket(header.messageLength - 16);
if (!bodyBuffer) {
throw new MongoDriverError("Invalid response body");
Expand Down

0 comments on commit 1c553a7

Please sign in to comment.