summaryrefslogtreecommitdiffstats
path: root/src/server/uplink.c
diff options
context:
space:
mode:
authorSimon Rettberg2019-01-31 10:23:46 +0100
committerSimon Rettberg2019-01-31 10:23:46 +0100
commit735015a7e6ff60a4f24b5c112c146b283d7ccaf1 (patch)
tree930fb68ecfcfb354a7d2abcfe0205dc0d64d26be /src/server/uplink.c
parent[SERVER] Lower log-level of non-critical message (diff)
downloaddnbd3-735015a7e6ff60a4f24b5c112c146b283d7ccaf1.tar.gz
dnbd3-735015a7e6ff60a4f24b5c112c146b283d7ccaf1.tar.xz
dnbd3-735015a7e6ff60a4f24b5c112c146b283d7ccaf1.zip
[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.
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r--src/server/uplink.c4
1 files changed, 4 insertions, 0 deletions
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 );