Change in pysim[master]: utils: fix sw_match()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Mar 23 12:17:23 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/23457 )

Change subject: utils: fix sw_match()
......................................................................

utils: fix sw_match()

The SW_match function takes a given status word and compares it against
a pattern that may contain wildcards (x or ?). This works by creating a
masked version of the SW using a pattern first (each hex digit is
replaced by a wildcard charafter if the pattern has a wildcard in the
same position). Once this is done, the resulting masked version is
compared at the pattern. However, the current implementation can not
work, since it compares the input SW against the pattern to decide
wihich chrafters should be masked. The input SW never contains wildcard
charafters.

Change-Id: I805ad32160fcfcb8628bf919b64f7eee0fe03c7e
Related: OS#4963
---
M pySim/utils.py
1 file changed, 3 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/pySim/utils.py b/pySim/utils.py
index e1fb4c7..0848b01 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -787,12 +787,13 @@
 	sw_lower = sw.lower()
 	sw_masked = ""
 	for i in range(0, 4):
-		if sw_lower[i] == '?':
+		if pattern[i] == '?':
 			sw_masked = sw_masked + '?'
-		elif sw_lower[i] == 'x':
+		elif pattern[i] == 'x':
 			sw_masked = sw_masked + 'x'
 		else:
 			sw_masked = sw_masked + sw_lower[i]
+	# Compare the masked version against the pattern
 	return sw_masked == pattern
 
 def tabulate_str_list(str_list, width = 79, hspace = 2, lspace = 1, align_left = True):

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23457
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I805ad32160fcfcb8628bf919b64f7eee0fe03c7e
Gerrit-Change-Number: 23457
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210323/24b16190/attachment.htm>


More information about the gerrit-log mailing list