Message ID | CAOCpKqn51K_QEzk__doirKztMPTZMuKoqBSDW4wdoWbfoPhNVw@mail.gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Fix: check variable type of port before trying to split | expand |
On 11/21/19 12:36 PM, Joshua Schmidlkofer wrote: > I ran into a bug passing port numbers are integers to the python > policy tools. Here is a proposed fix. The subject line / one-line summary should be of the form "[PATCH] subsystem: logical description", e.g. "[PATCH] semanage: support integer port arguments". Also, s/are/as/ above. > > Signed-off-by: Joshua Schmidlkofer <joshua@joshuainnovates.us> > --- > 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]) > - > + Try to avoid unrelated whitespace changes in patches unless you happen to be touching the same lines and are fixing coding style issues. > if high > 65535: > raise ValueError(_("Invalid Port")) >
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"))
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@joshuainnovates.us> --- python/semanage/seobject.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)