From 5851c46103f0547fa224b6e0759852785773c14e Mon Sep 17 00:00:00 2001 From: wangmenglan Date: Tue, 23 Apr 2024 15:18:50 +0630 Subject: [PATCH] =?UTF-8?q?bugfix:=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/tfe_packet_io.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/common/src/tfe_packet_io.cpp b/common/src/tfe_packet_io.cpp index b2d052d..eda7b38 100644 --- a/common/src/tfe_packet_io.cpp +++ b/common/src/tfe_packet_io.cpp @@ -923,7 +923,6 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx) // finish writing if (mpack_writer_destroy(&writer) != mpack_ok) { - assert(0); if (data) { free(data); @@ -936,6 +935,13 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx) int raw_packet_header_len = s_ctx->ctrl_meta->l7offset; marsio_buff_malloc_global(packet_io->instance, tx_buffs, 1, 0, thread_seq); char *dst = marsio_buff_append(tx_buffs[0], raw_packet_header_len + size); + if (dst == NULL) + { + TFE_LOG_ERROR(logger, "%s: unable to send log_update packet, get marsio buff is NULL.", LOG_TAG_PKTIO); + if (data) + free(data); + return; + } memcpy(dst, raw_packet_header_data, raw_packet_header_len); memcpy(dst + raw_packet_header_len, data, size); @@ -1038,6 +1044,11 @@ static void packet_io_send_fake_pkt(struct packet_io_thread_ctx *thread, struct { meta.raw_len = fn[i](info, client_mac, server_mac, buffer, sizeof(buffer)); meta.raw_data = marsio_buff_append(tx_buffs[i], meta.raw_len); + if (meta.raw_data == NULL) + { + TFE_LOG_ERROR(logger, "%s: unable to send fake packet, get marsio buff is NULL.", LOG_TAG_PKTIO); + continue; + } memcpy(meta.raw_data, buffer, meta.raw_len); switch (i) @@ -1948,6 +1959,12 @@ void handle_decryption_packet_from_tap(const char *data, int len, void *args) } char *dst = marsio_buff_append(tx_buffs[0], len); + if (dst == NULL) + { + throughput_metrics_inc(&packet_io_fs->decrypt_rxdrop, 1, len); + TFE_LOG_ERROR(logger, "%s: unable to send decryption packet, get marsio buff is NULL.", LOG_TAG_PKTIO); + return; + } memcpy(dst, data, len); struct metadata meta = {0}; @@ -2043,12 +2060,24 @@ void handle_raw_packet_from_tap(const char *data, int len, void *args) if (header != NULL) { packet_len = len + header_len - sizeof(struct ethhdr); dst = marsio_buff_append(tx_buffs[0], packet_len); + if (dst == NULL) + { + throughput_metrics_inc(&packet_io_fs->tap_pkt_rxdrop, 1, len); + TFE_LOG_ERROR(logger, "%s: unable to send raw packet, get marsio buff is NULL.", LOG_TAG_PKTIO); + return; + } memcpy(dst, header, header_len); memcpy(dst + header_len, data + sizeof(struct ethhdr), len - sizeof(struct ethhdr)); } else { packet_len = len; dst = marsio_buff_append(tx_buffs[0], len); + if (dst == NULL) + { + throughput_metrics_inc(&packet_io_fs->tap_pkt_rxdrop, 1, len); + TFE_LOG_ERROR(logger, "%s: unable to send raw packet, get marsio buff is NULL.", LOG_TAG_PKTIO); + return; + } memcpy(dst, data, len); }