laurenceman / rpms / iptables

Forked from rpms/iptables 5 years ago
Clone

Blame SOURCES/libxt_string-Avoid-potential-array-out-of-bounds-acc.patch

9a3fa7
From d9b22d809995f16b2bc988c8f72d70a5cd3e86d1 Mon Sep 17 00:00:00 2001
9a3fa7
From: Phil Sutter <psutter@redhat.com>
9a3fa7
Date: Fri, 15 Mar 2019 17:50:10 +0100
9a3fa7
Subject: [PATCH] libxt_string: Avoid potential array out of bounds access
9a3fa7
9a3fa7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1525980
9a3fa7
Upstream Status: iptables commit 56d7ab42f3782
9a3fa7
9a3fa7
commit 56d7ab42f37829ab8d42f34b77fd630ce08f5a7c
9a3fa7
Author: Phil Sutter <phil@nwl.cc>
9a3fa7
Date:   Mon Sep 10 23:35:16 2018 +0200
9a3fa7
9a3fa7
    libxt_string: Avoid potential array out of bounds access
9a3fa7
9a3fa7
    The pattern index variable 'sindex' is bounds checked before
9a3fa7
    incrementing it, which means in the next loop iteration it might already
9a3fa7
    match the bounds check condition but is used anyway.
9a3fa7
9a3fa7
    Fix this by incrementing the index before performing the bounds check.
9a3fa7
9a3fa7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
9a3fa7
    Signed-off-by: Florian Westphal <fw@strlen.de>
9a3fa7
9a3fa7
Signed-off-by: Phil Sutter <psutter@redhat.com>
9a3fa7
---
9a3fa7
 extensions/libxt_string.c | 3 +--
9a3fa7
 1 file changed, 1 insertion(+), 2 deletions(-)
9a3fa7
9a3fa7
diff --git a/extensions/libxt_string.c b/extensions/libxt_string.c
9a3fa7
index fb15980e4a73f..d298c6a7081e7 100644
9a3fa7
--- a/extensions/libxt_string.c
9a3fa7
+++ b/extensions/libxt_string.c
9a3fa7
@@ -159,9 +159,8 @@ parse_hex_string(const char *s, struct xt_string_info *info)
9a3fa7
 			info->pattern[sindex] = s[i];
9a3fa7
 			i++;
9a3fa7
 		}
9a3fa7
-		if (sindex > XT_STRING_MAX_PATTERN_SIZE)
9a3fa7
+		if (++sindex > XT_STRING_MAX_PATTERN_SIZE)
9a3fa7
 			xtables_error(PARAMETER_PROBLEM, "STRING too long \"%s\"", s);
9a3fa7
-		sindex++;
9a3fa7
 	}
9a3fa7
 	info->patlen = sindex;
9a3fa7
 }
9a3fa7
-- 
9a3fa7
2.21.0
9a3fa7