aboutsummaryrefslogtreecommitdiff
path: root/extensions/libebt_among.c
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2023-10-24 03:06:42 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-10-24 03:06:42 +0000
commit3b22e8041428d2a33076cd39f2cf1515bdbc6299 (patch)
tree45b4c93d87b3c713f64d4f1456de1e84b9ad0c6b /extensions/libebt_among.c
parent367ce4e075356677bcf5e7bfb792d2bd04dc7b9c (diff)
parent8e74bb6bb5c22858310f5414db20b67d4e206883 (diff)
downloadiptables-3b22e8041428d2a33076cd39f2cf1515bdbc6299.tar.gz
Merge changes from topics "ipt1810", "ipt189" into main am: 8e74bb6bb5
Original change: https://android-review.googlesource.com/c/platform/external/iptables/+/2799843 Change-Id: I613e1b0798ffcce14c4476d6b5f5914f7e022a70 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'extensions/libebt_among.c')
-rw-r--r--extensions/libebt_among.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/extensions/libebt_among.c b/extensions/libebt_among.c
index 7eb898f9..a80fb804 100644
--- a/extensions/libebt_among.c
+++ b/extensions/libebt_among.c
@@ -68,12 +68,12 @@ parse_nft_among_pair(char *buf, struct nft_among_pair *pair, bool have_ip)
if (!inet_pton(AF_INET, sep + 1, &pair->in))
xtables_error(PARAMETER_PROBLEM,
- "Invalid IP address '%s'\n", sep + 1);
+ "Invalid IP address '%s'", sep + 1);
}
ether = ether_aton(buf);
if (!ether)
xtables_error(PARAMETER_PROBLEM,
- "Invalid MAC address '%s'\n", buf);
+ "Invalid MAC address '%s'", buf);
memcpy(&pair->ether, ether, sizeof(*ether));
}
@@ -119,7 +119,6 @@ static int bramong_parse(int c, char **argv, int invert,
struct xt_entry_match **match)
{
struct nft_among_data *data = (struct nft_among_data *)(*match)->data;
- struct xt_entry_match *new_match;
bool have_ip, dst = false;
size_t new_size, cnt;
struct stat stats;
@@ -152,10 +151,9 @@ static int bramong_parse(int c, char **argv, int invert,
xtables_error(PARAMETER_PROBLEM,
"File should only contain one line");
optarg[flen-1] = '\0';
- /* fall through */
+ break;
case AMONG_DST:
- if (c == AMONG_DST)
- dst = true;
+ dst = true;
/* fall through */
case AMONG_SRC:
break;
@@ -171,18 +169,17 @@ static int bramong_parse(int c, char **argv, int invert,
new_size *= sizeof(struct nft_among_pair);
new_size += XT_ALIGN(sizeof(struct xt_entry_match)) +
sizeof(struct nft_among_data);
- new_match = xtables_calloc(1, new_size);
- memcpy(new_match, *match, (*match)->u.match_size);
- new_match->u.match_size = new_size;
- data = (struct nft_among_data *)new_match->data;
+ if (new_size > (*match)->u.match_size) {
+ *match = xtables_realloc(*match, new_size);
+ (*match)->u.match_size = new_size;
+ data = (struct nft_among_data *)(*match)->data;
+ }
+
have_ip = nft_among_pairs_have_ip(optarg);
poff = nft_among_prepare_data(data, dst, cnt, invert, have_ip);
parse_nft_among_pairs(data->pairs + poff, optarg, cnt, have_ip);
- free(*match);
- *match = new_match;
-
if (c == AMONG_DST_F || c == AMONG_SRC_F) {
munmap(argv, flen);
close(fd);