THRIFT-2937 Allow setting a maximum frame size

Set maximum frame size to 256MB (same as TNonblockingServer)

Client: cpp
Patch: Cristian Klein & Roger Meier
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index bedb5a5..62737af 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -201,6 +201,11 @@
     throw TTransportException("Frame size has negative value");
   }
 
+  // Check for oversized frame
+  if (sz > static_cast<int32_t>(maxFrameSize_))
+    throw TTransportException(TTransportException::CORRUPTED_DATA,
+                              "Received an oversized frame");
+
   // Read the frame payload, and reset markers.
   if (sz > static_cast<int32_t>(rBufSize_)) {
     rBuf_.reset(new uint8_t[sz]);
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h
index c94ae1e..9b5d51f 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.h
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.h
@@ -305,6 +305,7 @@
 class TFramedTransport : public TVirtualTransport<TFramedTransport, TBufferBase> {
 public:
   static const int DEFAULT_BUFFER_SIZE = 512;
+  static const int DEFAULT_MAX_FRAME_SIZE = 256 * 1024 * 1024;
 
   /// Use default buffer sizes.
   TFramedTransport(boost::shared_ptr<TTransport> transport)
@@ -365,6 +366,16 @@
    */
   virtual const std::string getOrigin() { return transport_->getOrigin(); }
 
+  /**
+   * Set the maximum size of the frame at read
+   */
+  void setMaxFrameSize(uint32_t maxFrameSize) { maxFrameSize_ = maxFrameSize; }
+
+  /**
+   * Get the maximum size of the frame at read
+   */
+  uint32_t getMaxFrameSize() { return maxFrameSize_; }
+
 protected:
   /**
    * Reads a frame of input from the underlying stream.
@@ -390,6 +401,7 @@
   boost::scoped_array<uint8_t> rBuf_;
   boost::scoped_array<uint8_t> wBuf_;
   uint32_t bufReclaimThresh_;
+  uint32_t maxFrameSize_ = DEFAULT_MAX_FRAME_SIZE;
 };
 
 /**