netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] extension/sctp: fix - mistake to pass a pointer where array is required
@ 2007-10-15 10:09 lizf
  2007-10-18  9:08 ` Patrick McHardy
  0 siblings, 1 reply; 3+ messages in thread
From: lizf @ 2007-10-15 10:09 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 1907 bytes --]


I resend this patch as attachment. Hope it can work.

--- iptables.orig/extensions/libxt_sctp.c	2007-10-12 11:04:23.000000000 +0800
+++ iptables/extensions/libxt_sctp.c	2007-10-12 11:10:11.000000000 +0800
@@ -398,15 +398,15 @@ print_chunk(u_int32_t chunknum, int nume
}

static void
-print_chunks(u_int32_t chunk_match_type, 
-	     const u_int32_t *chunkmap, 
-	     const struct xt_sctp_flag_info *flag_info,
-	     int flag_count,
-	     int numeric)
+print_chunks(const struct xt_sctp_info *einfo, int numeric)
{
	int i, j;
	int flag;

+	u_int32_t chunk_match_type = einfo->chunk_match_type;
+	const struct xt_sctp_flag_info *flag_info = einfo->flag_info;
+	int flag_count = einfo->flag_count;
+
	switch (chunk_match_type) {
		case SCTP_CHUNK_MATCH_ANY:	printf("any "); break;
		case SCTP_CHUNK_MATCH_ALL:	printf("all "); break;
@@ -414,19 +414,19 @@ print_chunks(u_int32_t chunk_match_type,
		default:	printf("Never reach herer\n"); break;
	}

-	if (SCTP_CHUNKMAP_IS_CLEAR(chunkmap)) {
+	if (SCTP_CHUNKMAP_IS_CLEAR(einfo->chunkmap)) {
		printf("NONE ");
		goto out;
	}
	
-	if (SCTP_CHUNKMAP_IS_ALL_SET(chunkmap)) {
+	if (SCTP_CHUNKMAP_IS_ALL_SET(einfo->chunkmap)) {
		printf("ALL ");
		goto out;
	}
	
	flag = 0;
	for (i = 0; i < 256; i++) {
-		if (SCTP_CHUNKMAP_IS_SET(chunkmap, i)) {
+		if (SCTP_CHUNKMAP_IS_SET(einfo->chunkmap, i)) {
			if (flag)
				printf(",");
			flag = 1;
@@ -473,8 +473,7 @@ sctp_print(const void *ip, const struct 
		if (einfo->invflags & XT_SCTP_CHUNK_TYPES) {
			printf("! ");
		}
-		print_chunks(einfo->chunk_match_type, einfo->chunkmap,
-			einfo->flag_info, einfo->flag_count, numeric);
+		print_chunks(einfo, numeric);
	}
}

@@ -509,8 +508,7 @@ static void sctp_save(const void *ip, co
			printf("! ");
		printf("--chunk-types ");

-		print_chunks(einfo->chunk_match_type, einfo->chunkmap, 
-			einfo->flag_info, einfo->flag_count, 0);
+		print_chunks(einfo, 0);
	}
}



[-- Attachment #2: libxt_sctp.patch --]
[-- Type: text/x-patch, Size: 1889 bytes --]

--- iptables.orig/extensions/libxt_sctp.c	2007-10-12 11:04:23.000000000 +0800
+++ iptables/extensions/libxt_sctp.c	2007-10-12 11:10:11.000000000 +0800
@@ -398,15 +398,15 @@ print_chunk(u_int32_t chunknum, int nume
 }
 
 static void
-print_chunks(u_int32_t chunk_match_type, 
-	     const u_int32_t *chunkmap, 
-	     const struct xt_sctp_flag_info *flag_info,
-	     int flag_count,
-	     int numeric)
+print_chunks(const struct xt_sctp_info *einfo, int numeric)
 {
 	int i, j;
 	int flag;
 
+	u_int32_t chunk_match_type = einfo->chunk_match_type;
+	const struct xt_sctp_flag_info *flag_info = einfo->flag_info;
+	int flag_count = einfo->flag_count;
+
 	switch (chunk_match_type) {
 		case SCTP_CHUNK_MATCH_ANY:	printf("any "); break;
 		case SCTP_CHUNK_MATCH_ALL:	printf("all "); break;
@@ -414,19 +414,19 @@ print_chunks(u_int32_t chunk_match_type,
 		default:	printf("Never reach herer\n"); break;
 	}
 
-	if (SCTP_CHUNKMAP_IS_CLEAR(chunkmap)) {
+	if (SCTP_CHUNKMAP_IS_CLEAR(einfo->chunkmap)) {
 		printf("NONE ");
 		goto out;
 	}
 	
-	if (SCTP_CHUNKMAP_IS_ALL_SET(chunkmap)) {
+	if (SCTP_CHUNKMAP_IS_ALL_SET(einfo->chunkmap)) {
 		printf("ALL ");
 		goto out;
 	}
 	
 	flag = 0;
 	for (i = 0; i < 256; i++) {
-		if (SCTP_CHUNKMAP_IS_SET(chunkmap, i)) {
+		if (SCTP_CHUNKMAP_IS_SET(einfo->chunkmap, i)) {
 			if (flag)
 				printf(",");
 			flag = 1;
@@ -473,8 +473,7 @@ sctp_print(const void *ip, const struct 
 		if (einfo->invflags & XT_SCTP_CHUNK_TYPES) {
 			printf("! ");
 		}
-		print_chunks(einfo->chunk_match_type, einfo->chunkmap,
-			einfo->flag_info, einfo->flag_count, numeric);
+		print_chunks(einfo, numeric);
 	}
 }
 
@@ -509,8 +508,7 @@ static void sctp_save(const void *ip, co
 			printf("! ");
 		printf("--chunk-types ");
 
-		print_chunks(einfo->chunk_match_type, einfo->chunkmap, 
-			einfo->flag_info, einfo->flag_count, 0);
+		print_chunks(einfo, 0);
 	}
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH] extension/sctp: fix - mistake to pass a pointer where array is required
@ 2007-10-12  5:35 lizf
  0 siblings, 0 replies; 3+ messages in thread
From: lizf @ 2007-10-12  5:35 UTC (permalink / raw)
  To: kaber, netfilter-devel

Hi,

Macros like SCTP_CHUNKMAP_XXX(chukmap) require chukmap to be an array,
We can see from below:
 
#define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))

#define SCTP_CHUNKMAP_RESET(chunkmap)				\
	do {							\
	int i;							\
		for (i = 0; i < ELEMCOUNT(chunkmap); i++)	\
		chunkmap[i] = 0;				\
	} while (0)

But print_chunks() passes a pointer to these macros. Here's the patch. 

--- iptables.orig/extensions/libxt_sctp.c	2007-10-12 11:04:23.000000000 +0800
+++ iptables/extensions/libxt_sctp.c	2007-10-12 11:10:11.000000000 +0800
@@ -398,15 +398,15 @@ print_chunk(u_int32_t chunknum, int nume
 }
 
 static void
-print_chunks(u_int32_t chunk_match_type, 
-	     const u_int32_t *chunkmap, 
-	     const struct xt_sctp_flag_info *flag_info,
-	     int flag_count,
-	     int numeric)
+print_chunks(const struct xt_sctp_info *einfo, int numeric)
 {
 	int i, j;
 	int flag;
 
+	u_int32_t chunk_match_type = einfo->chunk_match_type;
+	const struct xt_sctp_flag_info *flag_info = einfo->flag_info;
+	int flag_count = einfo->flag_count;
+
 	switch (chunk_match_type) {
 		case SCTP_CHUNK_MATCH_ANY:	printf("any "); break;
 		case SCTP_CHUNK_MATCH_ALL:	printf("all "); break;
@@ -414,19 +414,19 @@ print_chunks(u_int32_t chunk_match_type,
 		default:	printf("Never reach herer\n"); break;
 	}
 
-	if (SCTP_CHUNKMAP_IS_CLEAR(chunkmap)) {
+	if (SCTP_CHUNKMAP_IS_CLEAR(einfo->chunkmap)) {
 		printf("NONE ");
 		goto out;
 	}
 	
-	if (SCTP_CHUNKMAP_IS_ALL_SET(chunkmap)) {
+	if (SCTP_CHUNKMAP_IS_ALL_SET(einfo->chunkmap)) {
 		printf("ALL ");
 		goto out;
 	}
 	
 	flag = 0;
 	for (i = 0; i < 256; i++) {
-		if (SCTP_CHUNKMAP_IS_SET(chunkmap, i)) {
+		if (SCTP_CHUNKMAP_IS_SET(einfo->chunkmap, i)) {
 			if (flag)
 				printf(",");
 			flag = 1;
@@ -473,8 +473,7 @@ sctp_print(const void *ip, const struct 
 		if (einfo->invflags & XT_SCTP_CHUNK_TYPES) {
 			printf("! ");
 		}
-		print_chunks(einfo->chunk_match_type, einfo->chunkmap,
-			einfo->flag_info, einfo->flag_count, numeric);
+		print_chunks(einfo, numeric);
 	}
 }
 
@@ -509,8 +508,7 @@ static void sctp_save(const void *ip, co
 			printf("! ");
 		printf("--chunk-types ");
 
-		print_chunks(einfo->chunk_match_type, einfo->chunkmap, 
-			einfo->flag_info, einfo->flag_count, 0);
+		print_chunks(einfo, 0);
 	}
 }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-18  9:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-15 10:09 [PATCH] extension/sctp: fix - mistake to pass a pointer where array is required lizf
2007-10-18  9:08 ` Patrick McHardy
  -- strict thread matches above, loose matches on Subject: below --
2007-10-12  5:35 lizf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).