Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2067

requestid overflow

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.2.0, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7
    • Fix Version/s: 3.3.0
    • Component/s: core
    • Labels:
      None
    • MongoDB Version:
      4.0.2

      Description

      Hi,

      In file:
      https://github.com/mongodb-js/mongodb-core/blob/d40cb87ad415cfe224ae00d7696fc549fbbd0c62/lib/connection/msg.js#L105

       header.writeInt32LE(this.requestId, 4); // requestID
      

      requestId is used to write 2 bytes into header, but there is no limitation on how big this.requestId can be. It is growing with every message:

      https://github.com/mongodb-js/mongodb-core/blob/d40cb87ad415cfe224ae00d7696fc549fbbd0c62/lib/connection/msg.js#L133

      Msg.getRequestId = function() {
        return ++_requestId;
      };
      

      And so, eventually it will reach maximum allowed value +1 (I guess 32767+1).

      As node documentation is saying:

      https://nodejs.org/api/buffer.html#buffer_buf_writeint32le_value_offset

      value should be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

      In reality it means error which cannot be fixed even by re-connection to database:

      TypeError: "value" argument is out of bounds
      at checkInt (buffer.js:1185:11)
      at Buffer.writeInt32LE (buffer.js:1375:5)
      at Msg.toBin (/node_modules/mongodb/node_modules/mongodb-core/lib/connection/msg.js:105:12)
      

       

        Attachments

          Activity

            People

            Assignee:
            daniel.aprahamian Daniel Aprahamian (Inactive)
            Reporter:
            alexey.petrov@ringcentral.com alexey petrov
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: