Skip to content

Commit

Permalink
Backported CORE-5780: Server hangs when client tries to send too long…
Browse files Browse the repository at this point in the history
… DB encryption key(s)
  • Loading branch information
AlexPeshkoff committed Mar 19, 2018
1 parent 81908fd commit 27a6c41
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/remote/server/server.cpp
Expand Up @@ -145,9 +145,15 @@ class NetworkCallback : public VersionedIface<ICryptKeyCallbackImpl<NetworkCallb
{
if (l > length)
l = length;
memcpy(d, data, l);

wake = true;
if (data)
{
memcpy(d, data, l);
wake = true;
}
else
stop();

sem.release();
}

Expand Down Expand Up @@ -198,7 +204,7 @@ class CryptKeyCallback : public VersionedIface<ICryptKeyCallbackImpl<CryptKeyCal
loadClientKey();
unsigned rc = keyCallback ?
keyCallback->callback(dataLength, data, bufferLength, buffer) :
// use legacy behavior if holders to do wish to accept keys from client
// use legacy behavior if holders do wish to accept keys from client
networkCallback.callback(dataLength, data, bufferLength, buffer);

return rc;
Expand Down Expand Up @@ -6131,7 +6137,8 @@ SSHORT rem_port::asyncReceive(PACKET* asyncPacket, const UCHAR* buffer, SSHORT d
return 0;
}

switch (xdr_peek_long(&port_async_receive->port_receive, buffer, dataSize))
SLONG original_op = xdr_peek_long(&port_async_receive->port_receive, buffer, dataSize);
switch (original_op)
{
case op_cancel:
case op_abort_aux_connection:
Expand Down Expand Up @@ -6165,14 +6172,16 @@ SSHORT rem_port::asyncReceive(PACKET* asyncPacket, const UCHAR* buffer, SSHORT d
break;
case op_abort_aux_connection:
if (port_async && (port_async->port_flags & PORT_connecting))
{
port_async->abort_aux_connection();
}
break;
case op_crypt_key_callback:
port_server_crypt_callback->wakeup(asyncPacket->p_cc.p_cc_data.cstr_length,
asyncPacket->p_cc.p_cc_data.cstr_address);
break;
case op_partial:
if (original_op == op_crypt_key_callback)
port_server_crypt_callback->wakeup(0, NULL);
break;
default:
fb_assert(false);
return 0;
Expand Down

0 comments on commit 27a6c41

Please sign in to comment.