From: lizf <lizf@cn.fujitsu.com>
To: kaber@trash.net, netfilter-devel@vger.kernel.org
Subject: [PATCH] extension/sctp: fix - mistake to pass a pointer where array is required
Date: Fri, 12 Oct 2007 13:35:59 +0800 [thread overview]
Message-ID: <470F07BF.80606@cn.fujitsu.com> (raw)
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);
}
}
next reply other threads:[~2007-10-12 5:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 5:35 lizf [this message]
-- strict thread matches above, loose matches on Subject: below --
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=470F07BF.80606@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).