makssent opened a new pull request, #40181:
URL: https://github.com/apache/shardingsphere/pull/40181

   Changes proposed in this pull request:
     - Added `getLength` to `FirebirdConnectPacket` and `FirebirdAttachPacket`.
       - `op_connect` is written by 
[Jaybird](https://github.com/FirebirdSQL/jaybird/blob/v6.0.6/src/main/org/firebirdsql/gds/ng/wire/WireConnection.java#L393-L408)
 and read by 
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/remote/protocol.cpp#L320-L357).
       - `op_attach` is written by 
[Jaybird](https://github.com/FirebirdSQL/jaybird/blob/v6.0.6/src/main/org/firebirdsql/gds/ng/wire/version10/V10Database.java#L133-L145)
 and read by 
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/remote/protocol.cpp#L389-L397).
     - Previously, when `op_connect` or `op_attach` arrived in parts (for 
example, the first 16 bytes, a pause, the rest), the proxy took the first part 
for the whole packet. Parsing ran past its end, the client got `op_response` 
with error `isc_random`, and the proxy closed the connection. Now the proxy 
waits for the rest of the packet and answers as the Firebird server does for a 
whole packet (`op_accept_data`, then a successful login).
   
   <details>
   <summary>Verification</summary>
   
   The same protocol packets were executed directly against a real database and 
through the proxy, and the results were compared.
   
   * Server: Firebird 5.0
   * Clients: Jaybird 6.0.6
   
     Each packet is sent in two writes: the first 16 bytes, a pause of 200 ms, 
the rest. The pause makes the first part reach the server or the proxy in a 
separate socket read.
     - `op_connect` is sent to a new connection in one write and in two. The 
packet bytes are the same as Jaybird sends.
     - `op_attach`. Jaybird connects through an intermediate program that 
forwards its bytes unchanged but passes `op_attach` in two writes. After login, 
`SELECT 1 FROM RDB$DATABASE` is executed.
   
     Before the fix:
   
     | Packet | Proxy | Server | Match |
     |---|---|---|---|
     | `op_connect` in one write | `op_accept_data` | `op_accept_data` | yes |
     | `op_connect` in two writes | `op_response`, error `isc_random` `Unknown 
exception. More details: java.lang.IndexOutOfBoundsException: readerIndex(16) + 
length(4) exceeds writerIndex(16): PooledSlicedByteBuf(ridx: 16, widx: 16, cap: 
16/16, ...)` | `op_accept_data` | no |
     | `op_attach` in two writes, then `SELECT 1 FROM RDB$DATABASE` | error 
`isc_random` `Unknown exception.` | logged in, result 1 | no |
   
     After the fix:
   
     | Packet | Proxy | Server | Match |
     |---|---|---|---|
     | `op_connect` in one write | `op_accept_data` | `op_accept_data` | yes |
     | `op_connect` in two writes | `op_accept_data` | `op_accept_data` | yes |
     | `op_attach` in two writes, then `SELECT 1 FROM RDB$DATABASE` | logged 
in, result 1 | logged in, result 1 | yes |
   
   </details>
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following 
options:
   - [x] My code follows the [code of 
conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) 
of this project.
   - [x] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the 
pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C 
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [x] I have added corresponding unit tests for my changes.
   - [ ] I have updated the Release Notes of the current development version. 
For more details, see [Update Release 
Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
   - [ ] I have specified the tool and the affected files or area for 
substantial AI assistance, as required by the [AI-assisted contribution policy].
   
   [AI-assisted contribution policy]: 
https://github.com/apache/shardingsphere/blob/master/AI_POLICY.md
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to