[MERGED] osmo-gsm-tester[master]: config: Fix crash in overlay()

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Nov 6 17:43:02 UTC 2017


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 <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list