8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 02:43:03 +01:00

backported fix for AV related with too many protocol versions in connect packet

This commit is contained in:
alexpeshkoff 2006-11-12 14:25:48 +00:00
parent ca7dfc361d
commit 66c3cb5e14

View File

@ -305,30 +305,48 @@ bool_t xdr_protocol(XDR* xdrs, PACKET* p)
return P_TRUE(xdrs, p);
case op_connect:
connect = &p->p_cnct;
MAP(xdr_enum,
reinterpret_cast<xdr_op&>(connect->p_cnct_operation));
MAP(xdr_short,
reinterpret_cast<SSHORT&>(connect->p_cnct_cversion));
MAP(xdr_enum, reinterpret_cast<xdr_op&>(connect->p_cnct_client));
MAP(xdr_cstring, connect->p_cnct_file);
MAP(xdr_short, reinterpret_cast<SSHORT&>(connect->p_cnct_count));
MAP(xdr_cstring, connect->p_cnct_user_id);
for (i = 0, tail = connect->p_cnct_versions;
i < connect->p_cnct_count; i++, tail++)
{
MAP(xdr_short,
reinterpret_cast<SSHORT&>(tail->p_cnct_version));
connect = &p->p_cnct;
MAP(xdr_enum,
reinterpret_cast<xdr_op&>(tail->p_cnct_architecture));
MAP(xdr_u_short, tail->p_cnct_min_type);
MAP(xdr_u_short, tail->p_cnct_max_type);
reinterpret_cast<xdr_op&>(connect->p_cnct_operation));
MAP(xdr_short,
reinterpret_cast<SSHORT&>(tail->p_cnct_weight));
reinterpret_cast<SSHORT&>(connect->p_cnct_cversion));
MAP(xdr_enum, reinterpret_cast<xdr_op&>(connect->p_cnct_client));
MAP(xdr_cstring, connect->p_cnct_file);
MAP(xdr_short, reinterpret_cast<SSHORT&>(connect->p_cnct_count));
MAP(xdr_cstring, connect->p_cnct_user_id);
const size_t CNCT_VERSIONS = FB_NELEM(connect->p_cnct_versions);
for (i = 0, tail = connect->p_cnct_versions;
i < connect->p_cnct_count; i++, tail++)
{
// ignore the rest of protocols in case of too many suggested versions
p_cnct::p_cnct_repeat dummy;
if (i >= CNCT_VERSIONS)
{
tail = &dummy;
}
MAP(xdr_short,
reinterpret_cast<SSHORT&>(tail->p_cnct_version));
MAP(xdr_enum,
reinterpret_cast<xdr_op&>(tail->p_cnct_architecture));
MAP(xdr_u_short, tail->p_cnct_min_type);
MAP(xdr_u_short, tail->p_cnct_max_type);
MAP(xdr_short,
reinterpret_cast<SSHORT&>(tail->p_cnct_weight));
}
// ignore the rest of protocols in case of too many suggested versions
if (connect->p_cnct_count > CNCT_VERSIONS)
{
connect->p_cnct_count = CNCT_VERSIONS;
}
DEBUG_PRINTSIZE(xdrs, p->p_operation);
return P_TRUE(xdrs, p);
}
DEBUG_PRINTSIZE(xdrs, p->p_operation);
return P_TRUE(xdrs, p);
case op_accept:
accept = &p->p_acpt;