From 265dbe5dbc14c199299496c6db8fce3f76647015 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 21 Sep 2018 18:00:10 +0100 Subject: gentoo resync : 21.09.2018 --- .../files/libnftnl-1.1.1-big-endian-1.patch | 93 ++++++++++++++++++++++ .../files/libnftnl-1.1.1-big-endian-2.patch | 37 +++++++++ .../files/libnftnl-1.1.1-big-endian-3.patch | 33 ++++++++ 3 files changed, 163 insertions(+) create mode 100644 net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch create mode 100644 net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch create mode 100644 net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch (limited to 'net-libs/libnftnl/files') diff --git a/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch new file mode 100644 index 000000000000..e91333e21bb0 --- /dev/null +++ b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch @@ -0,0 +1,93 @@ +From 9737856067b97cbb869e04fc6b6e65c1d859f521 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 22 Jun 2018 14:18:57 +0200 +Subject: utils: Fix nftnl_get_value() on big endian + +This function basically did: + +| memcpy(out, val, ); + +which works only for little endian integer types. Fix this by assigning +the 64bit input value to a variable of the right size and use that as +input for above memcpy() call. + +Signed-off-by: Phil Sutter +--- + src/utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 42 insertions(+), 2 deletions(-) + +diff --git a/src/utils.c b/src/utils.c +index 3e44960..4d9ee78 100644 +--- a/src/utils.c ++++ b/src/utils.c +@@ -72,6 +72,15 @@ static struct { + + int nftnl_get_value(enum nftnl_type type, void *val, void *out) + { ++ union { ++ uint8_t u8; ++ uint16_t u16; ++ uint32_t u32; ++ int8_t s8; ++ int16_t s16; ++ int32_t s32; ++ } values; ++ void *valuep = NULL; + int64_t sval; + uint64_t uval; + +@@ -85,7 +94,6 @@ int nftnl_get_value(enum nftnl_type type, void *val, void *out) + errno = ERANGE; + return -1; + } +- memcpy(out, &uval, basetype[type].len); + break; + case NFTNL_TYPE_S8: + case NFTNL_TYPE_S16: +@@ -97,10 +105,42 @@ int nftnl_get_value(enum nftnl_type type, void *val, void *out) + errno = ERANGE; + return -1; + } +- memcpy(out, &sval, basetype[type].len); + break; + } + ++ switch (type) { ++ case NFTNL_TYPE_U8: ++ values.u8 = uval; ++ valuep = &values.u8; ++ break; ++ case NFTNL_TYPE_U16: ++ values.u16 = uval; ++ valuep = &values.u16; ++ break; ++ case NFTNL_TYPE_U32: ++ values.u32 = uval; ++ valuep = &values.u32; ++ break; ++ case NFTNL_TYPE_U64: ++ valuep = &uval; ++ break; ++ case NFTNL_TYPE_S8: ++ values.s8 = sval; ++ valuep = &values.s8; ++ break; ++ case NFTNL_TYPE_S16: ++ values.s16 = sval; ++ valuep = &values.s16; ++ break; ++ case NFTNL_TYPE_S32: ++ values.s32 = sval; ++ valuep = &values.s32; ++ break; ++ case NFTNL_TYPE_S64: ++ valuep = &sval; ++ break; ++ } ++ memcpy(out, valuep, basetype[type].len); + return 0; + } + +-- +cgit v1.2.1 + diff --git a/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch new file mode 100644 index 000000000000..c6fb5a25a893 --- /dev/null +++ b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch @@ -0,0 +1,37 @@ +From 5d592ce6c4596b25d5779a224d03c096bc25db54 Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 22 Jun 2018 14:18:58 +0200 +Subject: expr/data_reg: Fix JSON parsing on big endian + +Since reg->len is a 32bit variable, one needs to pass NFTNL_TYPE_U32 to +nftnl_jansson_parse_val(). Otherwise, only the most significant byte in +that variable is being written to. + +Since the value could potentially be larger than 255, increase node_name +buffer to avoid a compiler warning. + +Signed-off-by: Phil Sutter +--- + src/expr/data_reg.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c +index 1b28b29..ad7f4cb 100644 +--- a/src/expr/data_reg.c ++++ b/src/expr/data_reg.c +@@ -59,10 +59,10 @@ static int nftnl_data_reg_verdict_json_parse(union nftnl_data_reg *reg, json_t * + static int nftnl_data_reg_value_json_parse(union nftnl_data_reg *reg, json_t *data, + struct nftnl_parse_err *err) + { +- char node_name[8] = {}; /* strlen("data256") + 1 == 8 */ ++ char node_name[32] = {}; + int ret, remain = sizeof(node_name), offset = 0, i; + +- if (nftnl_jansson_parse_val(data, "len", NFTNL_TYPE_U8, ®->len, err) < 0) ++ if (nftnl_jansson_parse_val(data, "len", NFTNL_TYPE_U32, ®->len, err) < 0) + return DATA_NONE; + + for (i = 0; i < div_round_up(reg->len, sizeof(uint32_t)); i++) { +-- +cgit v1.2.1 + diff --git a/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch new file mode 100644 index 000000000000..d726ccfdc2d9 --- /dev/null +++ b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch @@ -0,0 +1,33 @@ +From 043060b18d27f24fe723e39bc2c9e5f50dde60dd Mon Sep 17 00:00:00 2001 +From: Phil Sutter +Date: Fri, 22 Jun 2018 14:18:59 +0200 +Subject: expr/exthdr: Fix JSON parsing on big endian + +When setting NFTNL_EXPR_EXTHDR_TYPE, one needs to call +nftnl_expr_set_u8() and not nftnl_expr_set_u32(). Otherwise 'type' +variable is assigned to uint32_t parameter before being passed to +nftnl_expr_exthdr_set() as void pointer which casts it to uint8_t. +On big endian systems, the latter would only consider the most +significant byte instead of the least significant one. + +Signed-off-by: Phil Sutter +--- + src/expr/exthdr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c +index 75cafbc..a351835 100644 +--- a/src/expr/exthdr.c ++++ b/src/expr/exthdr.c +@@ -270,7 +270,7 @@ nftnl_expr_exthdr_json_parse(struct nftnl_expr *e, json_t *root, + type = str2exthdr_type(exthdr_type); + if (type < 0) + return -1; +- nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_TYPE, type); ++ nftnl_expr_set_u8(e, NFTNL_EXPR_EXTHDR_TYPE, type); + } + + if (nftnl_jansson_parse_val(root, "offset", NFTNL_TYPE_U32, &uval32, +-- +cgit v1.2.1 + -- cgit v1.2.3