diff --git a/common/src/tfe_packet_io.cpp b/common/src/tfe_packet_io.cpp index 7ecb2e9..6d989b1 100644 --- a/common/src/tfe_packet_io.cpp +++ b/common/src/tfe_packet_io.cpp @@ -922,7 +922,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); @@ -935,6 +934,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); @@ -1037,6 +1043,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) @@ -1914,6 +1925,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}; @@ -2009,12 +2026,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); }