From 3ee08a91b35f050e4ccbaa3f641cf4e23d1a6d33 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Fri, 23 Dec 2022 16:24:41 +0000 Subject: conntrack: simplify calculation of `struct sock_fprog` length When assigning the length to the `struct sock_fprog` object, we calculate it by multiplying the number of `struct sock_filter` objects, `j`, by `sizeof(struct sock_filter)` and then dividing by `sizeof(bsf[0])`, which, since `bsf[0]` is a `struct sock_filter`, is equal to `sizeof(struct sock_filter)`. Remove the `sizeof` expressions and just assign `j`. Signed-off-by: Jeremy Sowden Signed-off-by: Pablo Neira Ayuso --- src/conntrack/bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conntrack/bsf.c b/src/conntrack/bsf.c index 589bfd8..35cc8b7 100644 --- a/src/conntrack/bsf.c +++ b/src/conntrack/bsf.c @@ -783,7 +783,7 @@ int __setup_netlink_socket_filter(int fd, struct nfct_filter *f) show_filter(bsf, from, j, "---- final verdict ----"); from = j; - sf.len = (sizeof(struct sock_filter) * j) / sizeof(bsf[0]); + sf.len = j; sf.filter = bsf; return setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &sf, sizeof(sf)); -- cgit v1.2.3