ff6046
From fbe394e9166ddfe847dcac0eab0fcbd3c225dc33 Mon Sep 17 00:00:00 2001
ff6046
From: David Tardon <dtardon@redhat.com>
ff6046
Date: Wed, 10 Oct 2018 09:33:28 +0200
ff6046
Subject: [PATCH] firewall-util: add an assert that we're not overwriting a
ff6046
 buffer
ff6046
ff6046
... like commit f28501279d2c28fdbb31d8273b723e9bf71d3b98 does for
ff6046
out_interface.
ff6046
ff6046
(cherry picked from commit 0b777d20e9a3868b12372ffce8040d1be063cec7)
ff6046
ff6046
Resolves: #1602706
ff6046
---
ff6046
 src/shared/firewall-util.c | 8 +++++++-
ff6046
 1 file changed, 7 insertions(+), 1 deletion(-)
ff6046
ff6046
diff --git a/src/shared/firewall-util.c b/src/shared/firewall-util.c
ff6046
index eb4f5ff616..cba52fb419 100644
ff6046
--- a/src/shared/firewall-util.c
ff6046
+++ b/src/shared/firewall-util.c
ff6046
@@ -50,8 +50,14 @@ static int entry_fill_basics(
ff6046
         entry->ip.proto = protocol;
ff6046
 
ff6046
         if (in_interface) {
ff6046
+                size_t l;
ff6046
+
ff6046
+                l = strlen(in_interface);
ff6046
+                assert(l < sizeof entry->ip.iniface);
ff6046
+                assert(l < sizeof entry->ip.iniface_mask);
ff6046
+
ff6046
                 strcpy(entry->ip.iniface, in_interface);
ff6046
-                memset(entry->ip.iniface_mask, 0xFF, strlen(in_interface)+1);
ff6046
+                memset(entry->ip.iniface_mask, 0xFF, l + 1);
ff6046
         }
ff6046
         if (source) {
ff6046
                 entry->ip.src = source->in;