You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ze...@apache.org on 2020/12/05 06:36:57 UTC

[thrift] branch master updated: Fix Missed check in c_glib for frame max message size check

This is an automated email from the ASF dual-hosted git repository.

zeshuai007 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new fb4b5aa  Fix Missed check in c_glib for frame max message size check
fb4b5aa is described below

commit fb4b5aa17b0542f6f75d9744ecfe904f57431331
Author: zeshuai007 <51...@qq.com>
AuthorDate: Sat Oct 31 14:39:13 2020 +0800

    Fix Missed check in c_glib for frame max message size check
---
 .../src/thrift/c_glib/transport/thrift_framed_transport.c   | 13 +++++++++++++
 .../src/thrift/c_glib/transport/thrift_framed_transport.h   |  1 +
 2 files changed, 14 insertions(+)

diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c
index f7b8192..3cbb245 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c
@@ -96,6 +96,14 @@ thrift_framed_transport_read_frame (ThriftTransport *transport,
     guchar *tmpdata;
 
     sz = ntohl (sz);
+    if (sz > t->max_frame_size)
+    {
+      g_set_error (error,
+                   THRIFT_TRANSPORT_ERROR,
+                   THRIFT_TRANSPORT_ERROR_MAX_MESSAGE_SIZE_REACHED,
+                   "Recived an oversized frame,");
+      return result;
+    }
 
     /* create a buffer to hold the data and read that much data */
     tmpdata = g_new0 (guchar, sz);
@@ -277,6 +285,7 @@ thrift_framed_transport_init (ThriftFramedTransport *transport)
   transport->transport = NULL;
   transport->r_buf = g_byte_array_new ();
   transport->w_buf = g_byte_array_new ();
+  transport->max_frame_size = DEFAULT_MAX_FRAME_SIZE;
 }
 
 /* destructor */
@@ -354,6 +363,10 @@ thrift_framed_transport_set_property (GObject *object, guint property_id,
       break;
     case PROP_THRIFT_FRAMED_TRANSPORT_CONFIGURATION:
       tt->configuration = g_value_dup_object (value);
+      if (tt->configuration != NULL)
+      {
+        transport->max_frame_size = tt->configuration->maxFrameSize_;
+      }
       break;
     case  PROP_THRIFT_FRAMED_TRANSPORT_REMAINING_MESSAGE_SIZE:
       tt->remainingMessageSize_ = g_value_get_long (value);
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.h b/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.h
index a102061..245cd21 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.h
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.h
@@ -53,6 +53,7 @@ struct _ThriftFramedTransport
   ThriftTransport *transport;
 
   /* private */
+  guint32 max_frame_size;
   GByteArray *r_buf;
   GByteArray *w_buf;
   guint32 r_buf_size;