Pau Espin Pedrol has submitted this change and it was merged.

Change subject: config: Fix crash in overlay()
......................................................................


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(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I4f8a191810e89a4081199edcb390fb3bb27ed42f
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofm...@sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to