Blob Blame History Raw
From e4dd398938aed75397463aed36fc03f9d754bf29 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Fri, 15 Mar 2019 17:51:28 +0100
Subject: [PATCH] libxtables: Check extension real_name length

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1525980
Upstream Status: iptables commit a3716cc1a501e

commit a3716cc1a501e40e26a96d78b2e1285bb081f366
Author: Phil Sutter <phil@nwl.cc>
Date:   Mon Sep 24 19:25:21 2018 +0200

    libxtables: Check extension real_name length

    Just like with 'name', if given check 'real_name' to not exceed max length.

    Signed-off-by: Phil Sutter <phil@nwl.cc>
    Signed-off-by: Florian Westphal <fw@strlen.de>

Signed-off-by: Phil Sutter <psutter@redhat.com>
---
 libxtables/xtables.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 575f7ee0a0d78..4a014e48a9f45 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -839,6 +839,12 @@ void xtables_register_match(struct xtables_match *me)
 		exit(1);
 	}
 
+	if (me->real_name && strlen(me->real_name) >= XT_EXTENSION_MAXNAMELEN) {
+		fprintf(stderr, "%s: match `%s' has invalid real name\n",
+			xt_params->program_name, me->real_name);
+		exit(1);
+	}
+
 	if (me->family >= NPROTO) {
 		fprintf(stderr,
 			"%s: BUG: match %s has invalid protocol family\n",
@@ -997,6 +1003,12 @@ void xtables_register_target(struct xtables_target *me)
 		exit(1);
 	}
 
+	if (me->real_name && strlen(me->real_name) >= XT_EXTENSION_MAXNAMELEN) {
+		fprintf(stderr, "%s: target `%s' has invalid real name\n",
+			xt_params->program_name, me->real_name);
+		exit(1);
+	}
+
 	if (me->family >= NPROTO) {
 		fprintf(stderr,
 			"%s: BUG: target %s has invalid protocol family\n",
-- 
2.21.0