@@ -2121,6 +2121,11 @@ static int CheckIp6Hdr(Ip6Hdr* iphdr, IpInfo* info, int length, char* error)
21212121 int version = IP_V (iphdr );
21222122 int exthdrsz = IP6_HDR_SZ ;
21232123
2124+ if (length < IP6_HDR_SZ ) {
2125+ SetError (BAD_IPVER_STR , error , NULL , 0 );
2126+ return WOLFSSL_FATAL_ERROR ;
2127+ }
2128+
21242129 TraceIP6 (iphdr );
21252130 Trace (IP_CHECK_STR );
21262131
@@ -2175,6 +2180,11 @@ static int CheckIpHdr(IpHdr* iphdr, IpInfo* info, int length, char* error,
21752180 if (version == IPV6 )
21762181 return CheckIp6Hdr ((Ip6Hdr * )iphdr , info , length , error );
21772182
2183+ if (length < IP_HDR_SZ ) {
2184+ SetError (PACKET_HDR_SHORT_STR , error , NULL , 0 );
2185+ return WOLFSSL_FATAL_ERROR ;
2186+ }
2187+
21782188 if (trace ) {
21792189 TraceIP (iphdr );
21802190 Trace (IP_CHECK_STR );
@@ -5026,6 +5036,10 @@ static const byte* DecryptMessage(WOLFSSL* ssl, const byte* input, word32 sz,
50265036
50275037#ifdef WOLFSSL_TLS13
50285038 if (IsAtLeastTLSv1_3 (ssl -> version )) {
5039+ if (sz < ssl -> specs .aead_mac_size ) {
5040+ * error = BUFFER_ERROR ;
5041+ return NULL ;
5042+ }
50295043 ret = DecryptTls13 (ssl , output , input , sz , (byte * )rh , RECORD_HEADER_SZ );
50305044 }
50315045 else
@@ -5404,6 +5418,12 @@ static int CheckHeaders(IpInfo* ipInfo, TcpInfo* tcpInfo, const byte* packet,
54045418 /* trim VLAN header and try again */
54055419 packet += 8 ;
54065420 length -= 8 ;
5421+ if (length < IP_HDR_SZ ) {
5422+ SetError (PACKET_HDR_SHORT_STR , error , NULL , 0 );
5423+ return WOLFSSL_FATAL_ERROR ;
5424+ }
5425+ iphdr = (IpHdr * )packet ;
5426+ version = IP_V (iphdr );
54075427 }
54085428 }
54095429
0 commit comments