From b23464c551d39becaef3cf42aabb7a710287274b Mon Sep 17 00:00:00 2001 From: Bart De Schuymer Date: Tue, 4 Mar 2008 19:14:29 +0000 Subject: fix for x86-64 (reported by Pavel Emelyanov) --- userspace/ebtables2/extensions/ebt_among.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/userspace/ebtables2/extensions/ebt_among.c b/userspace/ebtables2/extensions/ebt_among.c index 85bf0b5..001e9d6 100644 --- a/userspace/ebtables2/extensions/ebt_among.c +++ b/userspace/ebtables2/extensions/ebt_among.c @@ -68,6 +68,7 @@ static void print_help() " 00:00:00:fa:eb:fe=153.19.120.250,00:00:00:fa:eb:fe=192.168.0.1\n" ); } +static int old_size; static void init(struct ebt_entry_match *match) { @@ -75,6 +76,7 @@ static void init(struct ebt_entry_match *match) (struct ebt_among_info *) match->data; memset(amonginfo, 0, sizeof(struct ebt_among_info)); + old_size = sizeof(struct ebt_among_info); } static struct ebt_mac_wormhash *new_wormhash(int n) @@ -308,7 +310,7 @@ static int parse(int c, char **argv, int argc, (struct ebt_among_info *) (*match)->data; struct ebt_mac_wormhash *wh; struct ebt_entry_match *h; - int new_size, old_size; + int new_size; long flen; int fd; @@ -354,21 +356,21 @@ static int parse(int c, char **argv, int argc, if (ebt_errormsg[0] != '\0') break; - old_size = sizeof(struct ebt_entry_match) + (**match).match_size; - h = malloc((new_size = old_size + ebt_mac_wormhash_size(wh))); + new_size = old_size+ebt_mac_wormhash_size(wh); + h = malloc(sizeof(struct ebt_entry_match)+EBT_ALIGN(new_size)); if (!h) ebt_print_memory(); - memcpy(h, *match, old_size); - memcpy((char *) h + old_size, wh, ebt_mac_wormhash_size(wh)); - h->match_size = new_size - sizeof(struct ebt_entry_match); + memcpy(h, *match, old_size+sizeof(struct ebt_entry_match)); + memcpy((char *)h+old_size+sizeof(struct ebt_entry_match), wh, + ebt_mac_wormhash_size(wh)); + h->match_size = EBT_ALIGN(new_size); info = (struct ebt_among_info *) h->data; if (c == AMONG_DST) { - info->wh_dst_ofs = - old_size - sizeof(struct ebt_entry_match); + info->wh_dst_ofs = old_size; } else { - info->wh_src_ofs = - old_size - sizeof(struct ebt_entry_match); + info->wh_src_ofs = old_size; } + old_size = new_size; free(*match); *match = h; free(wh); @@ -476,7 +478,7 @@ static int compare(const struct ebt_entry_match *m1, } static struct ebt_u_match among_match = { - .name = "among", + .name = EBT_AMONG_MATCH, .size = sizeof(struct ebt_among_info), .help = print_help, .init = init, -- cgit v1.2.3