Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] varexpand: fix IndexError (bug 548556)
Date: Mon, 04 May 2015 06:02:31
Message-Id: 1430719318-28954-1-git-send-email-zmedico@gentoo.org
1 This handles two cases where varexpand incremented the index without
2 checking bounds.
3
4 X-Gentoo-Bug: 548556
5 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548556
6 X-Gentoo-forum-thread: https://forums.gentoo.org/viewtopic-t-1016432.html
7 ---
8 pym/portage/util/__init__.py | 12 ++++++++++++
9 1 file changed, 12 insertions(+)
10
11 diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
12 index 48cd1b7..c0b509b 100644
13 --- a/pym/portage/util/__init__.py
14 +++ b/pym/portage/util/__init__.py
15 @@ -850,8 +850,20 @@ def varexpand(mystring, mydict=None, error_leader=None):
16 continue
17 elif current == "$":
18 pos += 1
19 + if pos == length:
20 + # shells handle this like \$
21 + newstring.append(current)
22 + continue
23 +
24 if mystring[pos] == "{":
25 pos += 1
26 + if pos == length:
27 + msg = _varexpand_unexpected_eof_msg
28 + if error_leader is not None:
29 + msg = error_leader() + msg
30 + writemsg(msg + "\n", noiselevel=-1)
31 + return ""
32 +
33 braced = True
34 else:
35 braced = False
36 --
37 2.3.5

Replies