{"record":{"id":"58e95be8d8c70521","repo":"sqlmapproject/sqlmap","slug":"tds-message-exceeds-the-maximum-allowed-length-d","errorCode":null,"errorMessage":"TDS message exceeds the maximum allowed length (%d bytes)","messagePattern":"TDS message exceeds the maximum allowed length \\((.+?) bytes\\)","errorType":"exception","errorClass":"InterfaceError","httpStatus":null,"severity":"error","filePath":"extra/dbwire/tds.py","lineNumber":77,"sourceCode":"            raise connection_lost(ex)\n        packet_id += 1\n        if last:\n            break\n\ndef _read_message(sock):\n    # reassemble a full TDS message across packets (EOM status bit marks the last). The packet length is a\n    # 16-bit field, so bounding IT against _MAX_MESSAGE_LENGTH can never trigger - a hostile peer simply\n    # never sets EOM and streams packets forever. Bound the accumulated message instead, and collect the\n    # chunks in a list so reassembly stays linear rather than re-copying a growing immutable buffer.\n    chunks, total = [], 0\n    while True:\n        header = recvn(sock, 8)\n        mtype, status, length = struct.unpack(\">BBH\", header[:4])\n        if length < 8:\n            raise InterfaceError(\"invalid TDS packet length (%d)\" % length)\n        total += length - 8\n        if total > _MAX_MESSAGE_LENGTH:\n            raise InterfaceError(\"TDS message exceeds the maximum allowed length (%d bytes)\" % _MAX_MESSAGE_LENGTH)\n        chunks.append(recvn(sock, length - 8))\n        if status & _STATUS_EOM:\n            break\n    return b\"\".join(chunks)\n\n# ---- PRELOGIN ----------------------------------------------------------------------------------------\n\ndef _prelogin(sock):\n    ver = struct.pack(\">IH\", 0x11000000, 0)\n    enc = b\"\\x02\"  # ENCRYPT_NOT_SUP\n    tokens = b\"\\x00\" + struct.pack(\">HH\", 11, len(ver))\n    tokens += b\"\\x01\" + struct.pack(\">HH\", 11 + len(ver), len(enc))\n    tokens += b\"\\xff\"\n    _send_message(sock, _PKT_PRELOGIN, tokens + ver + enc)\n    body = _read_message(sock)\n    off = 0\n    while off < len(body) and _u8(body, off) != 0xff:\n        token = _u8(body, off)","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/sqlmapproject/sqlmap/blob/0a35b20e3953d341be6c7ac75ccb0b3362540c8d/extra/dbwire/tds.py#L59-L95","documentation":"Error \"TDS message exceeds the maximum allowed length (%d bytes)\" thrown in sqlmapproject/sqlmap.","triggerScenarios":"Thrown at extra/dbwire/tds.py:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0a35b20e3953d341be6c7ac75ccb0b3362540c8d","analyzedAt":"2026-08-26T23:02:52.002Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}