daandemeyer / rpms / systemd

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