diff options
author | zeshuai007 <51382517@qq.com> | 2020-10-31 14:39:13 +0800 |
---|---|---|
committer | Zezeng Wang <51382517@qq.com> | 2020-12-05 14:36:43 +0800 |
commit | fb4b5aa17b0542f6f75d9744ecfe904f57431331 (patch) | |
tree | c2ede8484d3c6c83d5a99be0f183e2e1f84d3f16 | |
parent | 12f6c31c8df739ccff271c8b81345d9a630c8921 (diff) | |
download | thrift-fb4b5aa17b0542f6f75d9744ecfe904f57431331.tar.gz |
Fix Missed check in c_glib for frame max message size check
-rw-r--r-- | lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c | 13 | ||||
-rw-r--r-- | lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.h | 1 |
2 files changed, 14 insertions, 0 deletions
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 f7b819260..3cbb245e0 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 a1020611a..245cd21c4 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; |