Skip to content

Commit

Permalink
[cleaner] Improve separating host from IPv6 address
Browse files Browse the repository at this point in the history
Fix a corner case in separating host address from an IPv6 address when
the host string is (substring of) the network address string.

Resolves: sosreport#3121
Relevant: sosreport#3120

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
  • Loading branch information
pmoravec authored and TurboTurtle committed Jan 26, 2023
1 parent 8c9db57 commit d19e8e6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions sos/cleaner/mappings/ipv6_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,9 @@ def _generate_address():
])

if addr.compressed not in self.hosts:
try:
_, _host = addr.compressed.split(self.network_addr.rstrip(':'))
except ValueError:
# network addr is simply '::'
_n, _host = addr.compressed.split(self.network_addr)
_host = _host.lstrip(':')
# separate host from the address by removing its network prefix
_n = self.network_addr.rstrip(':')
_host = addr.compressed[len(_n):].lstrip(':')
_ob_host = _generate_address()
while _ob_host in self.hosts.values():
_ob_host = _generate_address()
Expand Down

0 comments on commit d19e8e6

Please sign in to comment.