]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: libxt_sctp: Add an extra assert()
authorPhil Sutter <phil@nwl.cc>
Fri, 17 May 2024 13:20:05 +0000 (15:20 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 12 Jun 2024 15:14:27 +0000 (17:14 +0200)
The code is sane, but this keeps popping up in static code analyzers.

Signed-off-by: Phil Sutter <phil@nwl.cc>
extensions/libxt_sctp.c

index 6e2b2745dcbd565424f778fc05b5eabd250ebf6f..e8312f0c8abe99d4894a2f259afcb992302a6fdf 100644 (file)
@@ -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 {