From: Umang Sharma (umasharm) Date: Wed, 13 Dec 2023 20:25:39 +0000 (+0000) Subject: Pull request #4137: Coverity fixes X-Git-Tag: 3.1.77.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10712842b56cb12344f8e57342d886b2215a6e5f;p=thirdparty%2Fsnort3.git Pull request #4137: Coverity fixes Merge in SNORT/snort3 from ~UMASHARM/snort3:coverity_fixes to master Squashed commit of the following: commit f005a9908950f50692dc4ce1dba83c7b406da8eb Author: Umang Sharma Date: Fri Dec 8 11:40:39 2023 -0500 appid: fixes for coverity issues --- diff --git a/src/network_inspectors/appid/client_plugins/client_app_tns.cc b/src/network_inspectors/appid/client_plugins/client_app_tns.cc index 8ee79c11c..d66093139 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_tns.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_tns.cc @@ -152,6 +152,9 @@ int TnsClientDetector::validate(AppIdDiscoveryArgs& args) switch (fd->state) { case TNS_STATE_MESSAGE_LEN: + if (fd->pos >= 2) + break; + fd->l.raw_len[fd->pos++] = args.data[offset]; if (fd->pos >= offsetof(ClientTNSMsg, checksum)) { @@ -262,9 +265,11 @@ int TnsClientDetector::validate(AppIdDiscoveryArgs& args) fd->state = TNS_STATE_MESSAGE_CONNECT_OFFSET; break; case TNS_STATE_MESSAGE_CONNECT_OFFSET: + if (fd->pos >= CONNECT_DATA_OFFSET + 2) + break; fd->l.raw_len[fd->pos - CONNECT_DATA_OFFSET] = args.data[offset]; fd->pos++; - if (fd->pos >= (CONNECT_DATA_OFFSET + 2)) + if (fd->pos == (CONNECT_DATA_OFFSET + 2)) { fd->offsetlen = ntohs(fd->l.len); if (fd->offsetlen > args.size)