1 Star 0 Fork 31

Yuh_Kevin/iptables

forked from src-openEuler/iptables 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-add-check-fw-in-entry.patch 3.31 KB
一键复制 编辑 原始数据 按行查看 历史
haochen 提交于 2021-11-26 14:10 . synchronize some patches
From cbc3a30711701f0e8d7f5df14f84adfb2c9fec1f Mon Sep 17 00:00:00 2001
From: majun <majun65@huawei.com>
Date: Fri, 16 Apr 2021 14:52:42 +0800
Subject: [PATCH]
iptables: add null check for fw in X_entry
If the fw pointer is empty, a core dump occurs.
---
iptables/ip6tables.c | 21 +++++++++++++++++++++
iptables/iptables.c | 20 ++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index 576c2cf..db79906 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -557,6 +557,10 @@ append_entry(const xt_chainlabel chain,
unsigned int i, j;
int ret = 1;
+ if (!fw) {
+ return 0;
+ }
+
for (i = 0; i < nsaddrs; i++) {
fw->ipv6.src = saddrs[i];
fw->ipv6.smsk = smasks[i];
@@ -581,6 +585,11 @@ replace_entry(const xt_chainlabel chain,
int verbose,
struct xtc_handle *handle)
{
+
+ if (!fw) {
+ return 0;
+ }
+
fw->ipv6.src = *saddr;
fw->ipv6.dst = *daddr;
fw->ipv6.smsk = *smask;
@@ -607,6 +616,10 @@ insert_entry(const xt_chainlabel chain,
unsigned int i, j;
int ret = 1;
+ if (!fw) {
+ return 0;
+ }
+
for (i = 0; i < nsaddrs; i++) {
fw->ipv6.src = saddrs[i];
fw->ipv6.smsk = smasks[i];
@@ -674,6 +687,10 @@ delete_entry(const xt_chainlabel chain,
int ret = 1;
unsigned char *mask;
+ if (!fw) {
+ return 0;
+ }
+
mask = make_delete_mask(matches, target);
for (i = 0; i < nsaddrs; i++) {
fw->ipv6.src = saddrs[i];
@@ -704,6 +721,10 @@ check_entry(const xt_chainlabel chain, struct ip6t_entry *fw,
int ret = 1;
unsigned char *mask;
+ if (!fw) {
+ return 0;
+ }
+
mask = make_delete_mask(matches, target);
for (i = 0; i < nsaddrs; i++) {
fw->ipv6.src = saddrs[i];
diff --git a/iptables/iptables.c b/iptables/iptables.c
index 88ef6cf..6507603 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -549,6 +549,10 @@ append_entry(const xt_chainlabel chain,
unsigned int i, j;
int ret = 1;
+ if (!fw) {
+ return 0;
+ }
+
for (i = 0; i < nsaddrs; i++) {
fw->ip.src.s_addr = saddrs[i].s_addr;
fw->ip.smsk.s_addr = smasks[i].s_addr;
@@ -573,6 +577,10 @@ replace_entry(const xt_chainlabel chain,
int verbose,
struct xtc_handle *handle)
{
+ if (!fw) {
+ return 0;
+ }
+
fw->ip.src.s_addr = saddr->s_addr;
fw->ip.dst.s_addr = daddr->s_addr;
fw->ip.smsk.s_addr = smask->s_addr;
@@ -599,6 +607,10 @@ insert_entry(const xt_chainlabel chain,
unsigned int i, j;
int ret = 1;
+ if (!fw) {
+ return 0;
+ }
+
for (i = 0; i < nsaddrs; i++) {
fw->ip.src.s_addr = saddrs[i].s_addr;
fw->ip.smsk.s_addr = smasks[i].s_addr;
@@ -666,6 +678,10 @@ delete_entry(const xt_chainlabel chain,
int ret = 1;
unsigned char *mask;
+ if (!fw) {
+ return 0;
+ }
+
mask = make_delete_mask(matches, target);
for (i = 0; i < nsaddrs; i++) {
fw->ip.src.s_addr = saddrs[i].s_addr;
@@ -696,6 +712,10 @@ check_entry(const xt_chainlabel chain, struct ipt_entry *fw,
int ret = 1;
unsigned char *mask;
+ if (!fw) {
+ return 0;
+ }
+
mask = make_delete_mask(matches, target);
for (i = 0; i < nsaddrs; i++) {
fw->ip.src.s_addr = saddrs[i].s_addr;
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuh-kevin/iptables.git
git@gitee.com:yuh-kevin/iptables.git
yuh-kevin
iptables
iptables
master

搜索帮助