Skip to contentSkip to conversation

extensions: libxt_sctp: Add an extra assert()

PATCH In review Phil Sutter 1 participant 2 messages Jun 12, 2024 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 extensions: libxt_sctp: Add an extra assert()

The code is sane, but this keeps popping up in static code analyzers.

---
 extensions/libxt_sctp.c | 2 ++
 1 file changed, 2 insertions(+)
extensions/libxt_sctp.c +2 -0
index 6e2b2745dcbd5..e8312f0c8abe9 100644
@@ -7,6 +7,7 @@
  * libipt_ecn.c borrowed heavily from libipt_dscp.c
  *
  */
+#include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
@@ -354,6 +355,7 @@ print_chunk_flags(uint32_t chunknum, uint8_t chunk_flags, uint8_t chunk_flags_ma
 
 	for (i = 7; i >= 0; i--) {
 		if (chunk_flags_mask & (1 << i)) {
+			assert(chunknum < ARRAY_SIZE(sctp_chunk_names));
 			if (chunk_flags & (1 << i)) {
 				printf("%c", sctp_chunk_names[chunknum].valid_flags[7-i]);
 			} else {
Signature · 1 line
2.43.0