[PATCH] Fix: check variable type of port before trying to split

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I ran into a bug passing port numbers are integers to the python
policy tools.  Here is a proposed fix.

Signed-off-by: Joshua Schmidlkofer <joshua@xxxxxxxxxxxxxxxxxx>
---
 python/semanage/seobject.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index dc413ca5..c067222d 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
@@ -1070,13 +1070,17 @@ class portRecords(semanageRecords):
         if port == "":
             raise ValueError(_("Port is required"))

-        ports = port.split("-")
+        if isinstance(port, str):
+            ports = port.split('-', 1)
+        else:
+            ports = (port,)
+
         if len(ports) == 1:
             high = low = int(ports[0])
         else:
             low = int(ports[0])
             high = int(ports[1])
-
+
         if high > 65535:
             raise ValueError(_("Invalid Port"))

-- 
2.23.0



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux