1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Client should reject CLIENT-only error codes sent by the server

Per @vuvova in
https://github.com/mariadb-corporation/mariadb-connector-c/pull/223#issuecomment-1854720364:

> I don't think the client should accept client-side errors from the server
> at all.

If the server sends an error packet with error codes in the ranges
`CR_{MIN,MAX}_ERROR` (codes [2000, 2999]) or `CER_{MIN,MAX}_ERROR` (codes
[5000, 5999]), we will replace these with `CR_MALFORMED_PACKET`, rather than
propagating them to the client user.
This commit is contained in:
Daniel Lenski
2023-12-13 14:48:09 -08:00
committed by Sergei Golubchik
parent 00fb2062b9
commit 4419abe71a

View File

@@ -241,6 +241,17 @@ restart:
}
goto restart;
}
if (last_errno >= CR_MIN_ERROR && last_errno <= CR_MAX_ERROR ||
last_errno >= CER_MIN_ERROR && last_errno <= CER_MAX_ERROR)
{
/* The server appears to have sent an error code within the
* range(s) of error codes that should only be generated
* client-side.
*/
my_set_error(mysql, CR_MALFORMED_PACKET, SQLSTATE_UNKNOWN, 0);
}
else
{
net->last_errno= last_errno;
if (pos[0]== '#')
{
@@ -254,6 +265,7 @@ restart:
ma_strmake(net->last_error,(char*) pos,
min(len,sizeof(net->last_error)-1));
}
}
else
{
my_set_error(mysql, CR_UNKNOWN_ERROR, SQLSTATE_UNKNOWN, 0);