diff mbox

[nf-next] netfilter: xt_helper: Use sizeof(variable) instead of literal number

Message ID 1474338664-7258-1-git-send-email-fgao@ikuai8.com
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

高峰 Sept. 20, 2016, 2:31 a.m. UTC
From: Gao Feng <fgao@ikuai8.com>

It's better to use sizeof(info->name)-1 as index to force set the string
tail instead of literal number '29'.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
 net/netfilter/xt_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Sept. 22, 2016, 3:47 p.m. UTC | #1
On Tue, Sep 20, 2016 at 10:31:04AM +0800, fgao@ikuai8.com wrote:
> From: Gao Feng <fgao@ikuai8.com>
> 
> It's better to use sizeof(info->name)-1 as index to force set the string
> tail instead of literal number '29'.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index 9f4ab00..f71ee88 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -65,7 +65,7 @@  static int helper_mt_check(const struct xt_mtchk_param *par)
 			par->family);
 		return ret;
 	}
-	info->name[29] = '\0';
+	info->name[sizeof(info->name) - 1] = '\0';
 	return 0;
 }