You've already forked mariadb-connector-c
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:
committed by
Sergei Golubchik
parent
00fb2062b9
commit
4419abe71a
@@ -241,18 +241,30 @@ restart:
|
|||||||
}
|
}
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
net->last_errno= last_errno;
|
if (last_errno >= CR_MIN_ERROR && last_errno <= CR_MAX_ERROR ||
|
||||||
if (pos[0]== '#')
|
last_errno >= CER_MIN_ERROR && last_errno <= CER_MAX_ERROR)
|
||||||
{
|
{
|
||||||
ma_strmake(net->sqlstate, pos+1, SQLSTATE_LENGTH);
|
/* The server appears to have sent an error code within the
|
||||||
pos+= SQLSTATE_LENGTH + 1;
|
* range(s) of error codes that should only be generated
|
||||||
|
* client-side.
|
||||||
|
*/
|
||||||
|
my_set_error(mysql, CR_MALFORMED_PACKET, SQLSTATE_UNKNOWN, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(net->sqlstate, SQLSTATE_UNKNOWN, SQLSTATE_LENGTH);
|
net->last_errno= last_errno;
|
||||||
|
if (pos[0]== '#')
|
||||||
|
{
|
||||||
|
ma_strmake(net->sqlstate, pos+1, SQLSTATE_LENGTH);
|
||||||
|
pos+= SQLSTATE_LENGTH + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(net->sqlstate, SQLSTATE_UNKNOWN, SQLSTATE_LENGTH);
|
||||||
|
}
|
||||||
|
ma_strmake(net->last_error,(char*) pos,
|
||||||
|
min(len,sizeof(net->last_error)-1));
|
||||||
}
|
}
|
||||||
ma_strmake(net->last_error,(char*) pos,
|
|
||||||
min(len,sizeof(net->last_error)-1));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user