aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-05-22 21:50:46 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-05-23 08:25:40 -0400
commit4f36ea6eed2081340c7a7aa98c73187ecfccebff (patch)
tree295b214d5b19811ae7ffe450402af412daf109c8 /net/ipv4
parent2a7851bffb008ff4882eee673da74718997b4265 (diff)
netfilter: ipt_ULOG: fix non-null terminated string in the nf_log path
If nf_log uses ipt_ULOG as logging output, we can deliver non-null terminated strings to user-space since the maximum length of the prefix that is passed by nf_log is NF_LOG_PREFIXLEN but pm->prefix is 32 bytes long (ULOG_PREFIX_LEN). This is actually happening already from nf_conntrack_tcp if ipt_ULOG is used, since it is passing strings longer than 32 bytes. Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index cf08218ddbcf..ff4b781b1056 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -231,8 +231,10 @@ static void ipt_ulog_packet(struct net *net,
231 put_unaligned(tv.tv_usec, &pm->timestamp_usec); 231 put_unaligned(tv.tv_usec, &pm->timestamp_usec);
232 put_unaligned(skb->mark, &pm->mark); 232 put_unaligned(skb->mark, &pm->mark);
233 pm->hook = hooknum; 233 pm->hook = hooknum;
234 if (prefix != NULL) 234 if (prefix != NULL) {
235 strncpy(pm->prefix, prefix, sizeof(pm->prefix)); 235 strncpy(pm->prefix, prefix, sizeof(pm->prefix) - 1);
236 pm->prefix[sizeof(pm->prefix) - 1] = '\0';
237 }
236 else if (loginfo->prefix[0] != '\0') 238 else if (loginfo->prefix[0] != '\0')
237 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix)); 239 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
238 else 240 else