aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/ClientReadBuffer.cpp
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-04-15 12:41:23 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-04-15 12:41:23 +0200
commit9547a28faa9b4a9df02bea3cd55b011d615532e9 (patch)
tree8a51a34b718db91fd726bbaf1c0c8285e42af949 /nxcomp/ClientReadBuffer.cpp
parent6236266d4e18d4d264fab94643f9473ec3458e47 (diff)
downloadnx-libs-feature/nxcomp-bigreq-support.tar.gz
nx-libs-feature/nxcomp-bigreq-support.tar.bz2
nx-libs-feature/nxcomp-bigreq-support.zip
Add BIGREQUEST extension support to nxproxy/nxcomp.feature/nxcomp-bigreq-support
This work has been started by Paul Szarbo but has been discontinued before final completion. So, this is work in progress. For reference / communication history, see [1]. [1] https://bugs.debian.org/766299
Diffstat (limited to 'nxcomp/ClientReadBuffer.cpp')
-rw-r--r--nxcomp/ClientReadBuffer.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/nxcomp/ClientReadBuffer.cpp b/nxcomp/ClientReadBuffer.cpp
index 14aca3240..d164cf632 100644
--- a/nxcomp/ClientReadBuffer.cpp
+++ b/nxcomp/ClientReadBuffer.cpp
@@ -119,15 +119,34 @@ int ClientReadBuffer::locateMessage(const unsigned char *start,
dataLength = (GetUINT(start + 2, bigEndian_) << 2);
- if (dataLength < 4)
+ if (dataLength == 0) // or equivalently (dataLength < 4)
{
- #ifdef TEST
- *logofs << "ClientReadBuffer: WARNING! Assuming length 4 "
- << "for suspicious message of length " << dataLength
- << ".\n" << logofs_flush;
- #endif
-
- dataLength = 4;
+ // BIG-REQUESTS extension
+ if (size < 8)
+ {
+ remaining_ = 8 - size;
+ return 0;
+ }
+
+ dataLength = (GetULONG(start + 4, bigEndian_) << 2);
+
+// See WRITE_BUFFER_OVERFLOW_SIZE elsewhere
+// and also ENCODE_BUFFER_OVERFLOW_SIZE DECODE_BUFFER_OVERFLOW_SIZE.
+ if (dataLength < 8 || dataLength > 100*1024*1024)
+ {
+ #ifdef WARNING
+ *logofs << "BIG-REQUESTS with unacceptable dataLength="
+ << dataLength << ", now set to 8.\n" << logofs_flush;
+ #endif
+ dataLength = 8;
+ }
+ else if (dataLength < 4*64*1024)
+ {
+ #ifdef WARNING
+ *logofs << "BIG-REQUESTS with silly dataLength="
+ << dataLength << ".\n" << logofs_flush;
+ #endif
+ }
}
}