changeset 147:96488e9e9096

Report messages < 1 word as incomplete, and messages with crazily large estimated sizes as invalid
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 19 Jan 2017 10:48:45 +0000
parents c4f841ccb208
children c3b9a584b42b
files vamp-client/CapnpRRClient.h
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-client/CapnpRRClient.h	Thu Jan 19 09:57:58 2017 +0000
+++ b/vamp-client/CapnpRRClient.h	Thu Jan 19 10:48:45 2017 +0000
@@ -77,6 +77,10 @@
     public:
         State check(const std::vector<char> &message) const override {
 
+            if (message.size() < sizeof(capnp::word)) {
+                return Incomplete;
+            }
+            
             auto karr = toKJArray(message);
             size_t words = karr.size();
             size_t expected = capnp::expectedSizeInWordsFromPrefix(karr);
@@ -103,6 +107,9 @@
             } else if (words == expected) {
                 return Complete;
             } else if (expected > limit) {
+                std::cerr << "WARNING: apparently invalid message prefix: have "
+                          << words << " words in prefix, projected message size is "
+                          << expected << " against limit of " << limit << std::endl;
                 return Invalid;
             } else {
                 return Incomplete;