diff mbox series

[iptables] libxt_sctp: fix array out of range in print_chunk

Message ID 20171110104905.9205-1-nicolas.dichtel@6wind.com
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series [iptables] libxt_sctp: fix array out of range in print_chunk | expand

Commit Message

Nicolas Dichtel Nov. 10, 2017, 10:49 a.m. UTC
From: huaibin Wang <huaibin.wang@6wind.com>

For chunk type ASCONF, ASCONF_ACK and FORWARD_TSN, sctp_chunk_names[].chunk_type
is not equal to the corresponding index in sctp_chunk_names[]. Using this field
leads to a segmentation fault (index out of range).

Example
$ iptables -A INPUT -p sctp --chunk-type all ASCONF,ASCONF_ACK,FORWARD_TSN -j ACCEPT
$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
Segmentation fault

Signed-off-by: huaibin Wang <huaibin.wang@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 extensions/libxt_sctp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Nov. 13, 2017, 12:38 p.m. UTC | #1
Hi Nicolas,

On Fri, Nov 10, 2017 at 11:49:05AM +0100, Nicolas Dichtel wrote:
> From: huaibin Wang <huaibin.wang@6wind.com>
> 
> For chunk type ASCONF, ASCONF_ACK and FORWARD_TSN, sctp_chunk_names[].chunk_type
> is not equal to the corresponding index in sctp_chunk_names[]. Using this field
> leads to a segmentation fault (index out of range).
> 
> Example
> $ iptables -A INPUT -p sctp --chunk-type all ASCONF,ASCONF_ACK,FORWARD_TSN -j ACCEPT
> $ iptables -L
> Chain INPUT (policy ACCEPT)
> target     prot opt source               destination
> Segmentation fault
> 
> Signed-off-by: huaibin Wang <huaibin.wang@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  extensions/libxt_sctp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c
> index df1936be8b83..140de2653b1e 100644
> --- a/extensions/libxt_sctp.c
> +++ b/extensions/libxt_sctp.c
> @@ -370,7 +370,7 @@ print_chunk(uint32_t chunknum, int numeric)
>  
>  		for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
>  			if (sctp_chunk_names[i].chunk_type == chunknum)
> -				printf("%s", sctp_chunk_names[chunknum].name);
> +				printf("%s", sctp_chunk_names[i].name);

Can we get a test for iptables/extensions/libxt_sctp.t ?

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c
index df1936be8b83..140de2653b1e 100644
--- a/extensions/libxt_sctp.c
+++ b/extensions/libxt_sctp.c
@@ -370,7 +370,7 @@  print_chunk(uint32_t chunknum, int numeric)
 
 		for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
 			if (sctp_chunk_names[i].chunk_type == chunknum)
-				printf("%s", sctp_chunk_names[chunknum].name);
+				printf("%s", sctp_chunk_names[i].name);
 	}
 }