sync receive_message raises ValueError instead of ProtocolError for OP_COMPRESSED messages with 16 < length ≤ 25

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.18.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      receive_message (sync path) is missing the OP_COMPRESSED minimum-length guard that exists in the async PyMongoProtocol.process_header.

      PyMongoProtocol.process_header has the correct guard:

      if op_code == 2012:
          if length <= 25:
              raise ProtocolError(
                  f"Message length ({length!r}) not longer than standard OP_COMPRESSED message header size (25)"
              )

      Definition of done

      Add the same guard to receive_message before entering the op_code == 2012 branch:

      if op_code == 2012:
          if length <= 25:
              raise ProtocolError(
                  f"Message length ({length!r}) not longer than standard OP_COMPRESSED message header size (25)"
              )
          ...

      Pitfalls

      NA

            Assignee:
            Alex Clark
            Reporter:
            Alex Clark
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: