summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-05-16 14:04:56 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-05-16 14:04:56 +0200
commit493aae46b3aeffcdb001f697efdc5a42eba672d8 (patch)
treee58f6aad6bab2a0ab6726429c9efa0909f6e81e4 /common
parentef5bdf968dc947730e4421c8e1c9c1773c0b3db0 (diff)
downloadsink-493aae46b3aeffcdb001f697efdc5a42eba672d8.tar.gz
sink-493aae46b3aeffcdb001f697efdc5a42eba672d8.zip
Better debug messages if the command is too small
Diffstat (limited to 'common')
-rw-r--r--common/resourceaccess.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp
index 6863193..e49802b 100644
--- a/common/resourceaccess.cpp
+++ b/common/resourceaccess.cpp
@@ -600,7 +600,8 @@ bool ResourceAccess::processMessageBuffer()
600{ 600{
601 static const int headerSize = Commands::headerSize(); 601 static const int headerSize = Commands::headerSize();
602 if (d->partialMessageBuffer.size() < headerSize) { 602 if (d->partialMessageBuffer.size() < headerSize) {
603 SinkWarning() << "command too small"; 603 //This is not an error
604 SinkTrace() << "command too small, smaller than headerSize: " << d->partialMessageBuffer.size() << headerSize;
604 return false; 605 return false;
605 } 606 }
606 607
@@ -608,8 +609,10 @@ bool ResourceAccess::processMessageBuffer()
608 const int commandId = *(const int *)(d->partialMessageBuffer.constData() + sizeof(uint)); 609 const int commandId = *(const int *)(d->partialMessageBuffer.constData() + sizeof(uint));
609 const uint size = *(const int *)(d->partialMessageBuffer.constData() + sizeof(int) + sizeof(uint)); 610 const uint size = *(const int *)(d->partialMessageBuffer.constData() + sizeof(int) + sizeof(uint));
610 611
611 if (size > (uint)(d->partialMessageBuffer.size() - headerSize)) { 612 const uint availableMessageSize = d->partialMessageBuffer.size() - headerSize;
612 SinkWarning() << "command too small"; 613 if (size > availableMessageSize) {
614 //This is not an error
615 SinkTrace() << "command too small, message smaller than advertised: " << availableMessageSize << headerSize;
613 return false; 616 return false;
614 } 617 }
615 618