Skip to content

Commit

Permalink
netfilter: x_tables: rectify XT_FUNCTION_MAXNAMELEN usage
Browse files Browse the repository at this point in the history
There has been quite a confusion in userspace about
XT_FUNCTION_MAXNAMELEN; because struct xt_entry_match used MAX-1,
userspace would have to do an awkward MAX-2 for maximum length
checking (due to '\0'). This patch adds a new define that matches the
definition of XT_TABLE_MAXNAMELEN - being the size of the actual
struct member, not one off.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
  • Loading branch information
Jan Engelhardt authored and Patrick McHardy committed Apr 27, 2010
1 parent af740b2 commit 4b2cbd4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions include/linux/netfilter/x_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/types.h>

#define XT_FUNCTION_MAXNAMELEN 30
#define XT_EXTENSION_MAXNAMELEN 29
#define XT_TABLE_MAXNAMELEN 32

struct xt_entry_match {
Expand All @@ -12,8 +13,7 @@ struct xt_entry_match {
__u16 match_size;

/* Used by userspace */
char name[XT_FUNCTION_MAXNAMELEN-1];

char name[XT_EXTENSION_MAXNAMELEN];
__u8 revision;
} user;
struct {
Expand All @@ -36,8 +36,7 @@ struct xt_entry_target {
__u16 target_size;

/* Used by userspace */
char name[XT_FUNCTION_MAXNAMELEN-1];

char name[XT_EXTENSION_MAXNAMELEN];
__u8 revision;
} user;
struct {
Expand Down Expand Up @@ -70,8 +69,7 @@ struct xt_standard_target {
/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
* kernel supports, if >= revision. */
struct xt_get_revision {
char name[XT_FUNCTION_MAXNAMELEN-1];

char name[XT_EXTENSION_MAXNAMELEN];
__u8 revision;
};

Expand Down Expand Up @@ -291,7 +289,7 @@ struct xt_tgdtor_param {
struct xt_match {
struct list_head list;

const char name[XT_FUNCTION_MAXNAMELEN-1];
const char name[XT_EXTENSION_MAXNAMELEN];
u_int8_t revision;

/* Return true or false: return FALSE and set *hotdrop = 1 to
Expand Down Expand Up @@ -330,7 +328,7 @@ struct xt_match {
struct xt_target {
struct list_head list;

const char name[XT_FUNCTION_MAXNAMELEN-1];
const char name[XT_EXTENSION_MAXNAMELEN];
u_int8_t revision;

/* Returns verdict. Argument order changed since 2.6.9, as this
Expand Down

0 comments on commit 4b2cbd4

Please sign in to comment.