Fix: relay_recv_metadata does not check for partial write
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 25 Apr 2018 18:57:29 +0000 (14:57 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Apr 2018 15:42:04 +0000 (11:42 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
src/bin/lttng-relayd/main.c
src/common/defaults.h

index 5173b1ea9c778063c7bcfb3ade9c18a88b243acb..a99c0d3c5fafa5a66b9f08d5c4e67a08f573891c 100644 (file)
@@ -366,6 +366,7 @@ _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_AGENT_BIND_ADDRESS], [localhost])
 _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_NETWORK_CONTROL_BIND_ADDRESS], [0.0.0.0])
 _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_NETWORK_DATA_BIND_ADDRESS], [0.0.0.0])
 _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_NETWORK_VIEWER_BIND_ADDRESS], [localhost])
+_AC_DEFINE_AND_SUBST([DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE], [134217728])
 _AC_DEFINE_AND_SUBST([DEFAULT_ROTATE_PENDING_RELAY_TIMER], [200000])
 
 # Command short descriptions
index 44ea6cdeee8cd06baf8e0127032de7fc0b4aed03..cf6d8ba2397178be15ac64da636bd7c9caec6b0c 100644 (file)
@@ -1808,7 +1808,7 @@ static int relay_recv_metadata(const struct lttcomm_relayd_hdr *recv_hdr,
 
        size_ret = write_padding_to_file(metadata_stream->stream_fd->fd,
                        metadata_payload_header.padding_size);
-       if (size_ret < 0) {
+       if (size_ret < (int64_t) metadata_payload_header.padding_size) {
                ret = -1;
                goto end_put;
        }
@@ -3068,8 +3068,7 @@ static int relay_process_control_receive_header(struct relay_connection *conn)
                        conn->sock->fd, header.cmd, header.cmd_version,
                        header.data_size);
 
-       /* FIXME temporary arbitrary limit on data size. */
-       if (header.data_size > (128 * 1024 * 1024)) {
+       if (header.data_size > DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE) {
                ERR("Command header indicates a payload (%" PRIu64 " bytes) that exceeds the maximal payload size allowed on a control connection.",
                                header.data_size);
                ret = -1;
index e0f4438c80ea9a2637ec8396c2ddfae9bf68e5c0..fabcf085204227d04333d6e51ddf6292b2c1c4b1 100644 (file)
  */
 #define DEFAULT_INET_TCP_TIMEOUT                       180     /* sec */
 
+/* Maximum payload size for a control connection */
+
+#define DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE CONFIG_DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE
+
 /*
  * Default receiving and sending timeout for an application socket.
  */
This page took 0.040282 seconds and 5 git commands to generate.