I found an error on the C cli when processing a chunked response from the server.
I'm able to reproduce the issue only when the server runs in insecure mode.
Minimal environment to make it happen:
run the core locally with insecure flag
connect with the cli
run CREATE DATABASE db1.sqlite; CREATE DATABASE db2.sqlite
If the client reads from the socket each one of the 3 packets individually or the first 2 in a single read and the third in a following read (like it seems to always happpen with TLS), the sdk/cli works fine.
Otherwise, if the sdk/cli reads all the received data in a single read (like it frequently happens without TLS) then it fires an error in internal_socket_read. The issue is in sqcloud.c lines 1470-1480:
because in this case tread includes the end chunk (it's value is 56) but clen + cstart + 1 only consider the real content (43+3+1 = 47) and the following blen = (clen + cstart + 1) - tread; is lower than 0 but the value is uint64 so it's value is represented as 4294967287 and the following read will fail with error code 22 Invalid argument because of this blen value.
I found an error on the C cli when processing a chunked response from the server. I'm able to reproduce the issue only when the server runs in insecure mode. Minimal environment to make it happen:
CREATE DATABASE db1.sqlite; CREATE DATABASE db2.sqlite
SET CLIENT KEY MAXROWS TO 2
LIST DATABASES
The server send the following buffers
If the client reads from the socket each one of the 3 packets individually or the first 2 in a single read and the third in a following read (like it seems to always happpen with TLS), the sdk/cli works fine. Otherwise, if the sdk/cli reads all the received data in a single read (like it frequently happens without TLS) then it fires an error in
internal_socket_read
. The issue is in sqcloud.c lines 1470-1480:because in this case
tread
includes the end chunk (it's value is 56) butclen + cstart + 1
only consider the real content (43+3+1 = 47) and the followingblen = (clen + cstart + 1) - tread;
is lower than 0 but the value is uint64 so it's value is represented as 4294967287 and the following read will fail with error code 22Invalid argument
because of this blen value.