Review at  https://gerrit.osmocom.org/4422

config: Fix crash in overlay()

if len(src) > len(dest), then we hit an out-of-bounds crash accessing dest[i].

It is totally valid to have src and dest with different lens, as you may
want to override only part of the list.

Change-Id: I4f8a191810e89a4081199edcb390fb3bb27ed42f
---
M src/osmo_gsm_tester/config.py
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/22/4422/1

diff --git a/src/osmo_gsm_tester/config.py b/src/osmo_gsm_tester/config.py
index 0721c30..7f1e52f 100644
--- a/src/osmo_gsm_tester/config.py
+++ b/src/osmo_gsm_tester/config.py
@@ -281,9 +281,12 @@
     if is_list(dest):
         if not is_list(src):
             raise ValueError('cannot combine list with a value of type: %r' % 
type(src))
-        for i in range(len(src)):
+        copy_len = min(len(src),len(dest))
+        for i in range(copy_len):
             log.ctx(idx=i)
             dest[i] = overlay(dest[i], src[i])
+        for i in range(copy_len, len(src)):
+            dest.append(src[i])
         return dest
     return src
 

-- 
To view, visit https://gerrit.osmocom.org/4422
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f8a191810e89a4081199edcb390fb3bb27ed42f
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <[email protected]>

Reply via email to