diff mbox series

netfilter: Don't parse CTCP message if shorter than minimum length

Message ID 20230621032953.107143-1-sohomdatta1+git@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series netfilter: Don't parse CTCP message if shorter than minimum length | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch warning WARNING: From:/Signed-off-by: email subaddress mismatch: 'From: Sohom <sohomdatta1@gmail.com>' != 'Signed-off-by: Sohom <sohomdatta1+git@gmail.com>'
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sohom June 21, 2023, 3:29 a.m. UTC
If the CTCP message is shorter than 10 + 21 + MINMATCHLEN
then exit early and don't parse the rest of the message.

Signed-off-by: Sohom <sohomdatta1+git@gmail.com>
---
 net/netfilter/nf_conntrack_irc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Florian Westphal June 21, 2023, 8:44 a.m. UTC | #1
Sohom <sohomdatta1@gmail.com> wrote:
> If the CTCP message is shorter than 10 + 21 + MINMATCHLEN
> then exit early and don't parse the rest of the message.

Please send a v2 explaining why, not what.

> +	if (data >= data_limit - (10 + 21 + MINMATCHLEN)) {
> +		goto out;
> +	}

Please run your patches through scripts/checkpatch.pl,
we don't use { } for single-line conditional bodies.

>  	/* Skip any whitespace */
> -	while (data < data_limit - 10) {
> +	while (data < data_limit) {

Why this change?
diff mbox series

Patch

diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c
index 5703846bea3b..703b5a123cb5 100644
--- a/net/netfilter/nf_conntrack_irc.c
+++ b/net/netfilter/nf_conntrack_irc.c
@@ -157,8 +157,12 @@  static int help(struct sk_buff *skb, unsigned int protoff,
 	data = ib_ptr;
 	data_limit = ib_ptr + datalen;
 
+	if (data >= data_limit - (10 + 21 + MINMATCHLEN)) {
+		goto out;
+	}
+
 	/* Skip any whitespace */
-	while (data < data_limit - 10) {
+	while (data < data_limit) {
 		if (*data == ' ' || *data == '\r' || *data == '\n')
 			data++;
 		else