From 735015a7e6ff60a4f24b5c112c146b283d7ccaf1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 31 Jan 2019 10:23:46 +0100 Subject: [SERVER] uplink: Check for _maxPayload when getting client request It didn't make too much sense that we only checked _maxPayload when the reply arrived; simply don't forward a request where we already know we won't handle the reply. --- src/server/uplink.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/server/uplink.c') diff --git a/src/server/uplink.c b/src/server/uplink.c index ef8f893..d544795 100644 --- a/src/server/uplink.c +++ b/src/server/uplink.c @@ -163,6 +163,10 @@ void uplink_removeClient(dnbd3_connection_t *uplink, dnbd3_client_t *client) bool uplink_request(dnbd3_client_t *client, uint64_t handle, uint64_t start, uint32_t length, uint8_t hops) { if ( client == NULL || client->image == NULL ) return false; + if ( length > (uint32_t)_maxPayload ) { + logadd( LOG_WARNING, "Cannot relay request by client; length of %" PRIu32 " exceeds maximum payload", length ); + return false; + } spin_lock( &client->image->lock ); if ( client->image->uplink == NULL ) { spin_unlock( &client->image->lock ); -- cgit v1.2.3-55-g7522