* [gentoo-portage-dev] [PATCH] varexpand: fix IndexError (bug 548556)
@ 2015-05-04 6:01 Zac Medico
2015-05-04 6:22 ` Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2015-05-04 6:01 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
This handles two cases where varexpand incremented the index without
checking bounds.
X-Gentoo-Bug: 548556
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548556
X-Gentoo-forum-thread: https://forums.gentoo.org/viewtopic-t-1016432.html
---
pym/portage/util/__init__.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 48cd1b7..c0b509b 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -850,8 +850,20 @@ def varexpand(mystring, mydict=None, error_leader=None):
continue
elif current == "$":
pos += 1
+ if pos == length:
+ # shells handle this like \$
+ newstring.append(current)
+ continue
+
if mystring[pos] == "{":
pos += 1
+ if pos == length:
+ msg = _varexpand_unexpected_eof_msg
+ if error_leader is not None:
+ msg = error_leader() + msg
+ writemsg(msg + "\n", noiselevel=-1)
+ return ""
+
braced = True
else:
braced = False
--
2.3.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] varexpand: fix IndexError (bug 548556)
2015-05-04 6:01 [gentoo-portage-dev] [PATCH] varexpand: fix IndexError (bug 548556) Zac Medico
@ 2015-05-04 6:22 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-05-04 6:22 UTC (permalink / raw
To: gentoo-portage-dev
On Sun, 3 May 2015 23:01:58 -0700
Zac Medico <zmedico@gentoo.org> wrote:
> This handles two cases where varexpand incremented the index without
> checking bounds.
>
> X-Gentoo-Bug: 548556
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548556
> X-Gentoo-forum-thread:
> https://forums.gentoo.org/viewtopic-t-1016432.html ---
> pym/portage/util/__init__.py | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/pym/portage/util/__init__.py
> b/pym/portage/util/__init__.py index 48cd1b7..c0b509b 100644
> --- a/pym/portage/util/__init__.py
> +++ b/pym/portage/util/__init__.py
> @@ -850,8 +850,20 @@ def varexpand(mystring, mydict=None,
> error_leader=None): continue
> elif current == "$":
> pos += 1
> + if pos == length:
> + # shells handle this like \$
> + newstring.append(current)
> + continue
> +
> if mystring[pos] == "{":
> pos += 1
> + if pos == length:
> + msg =
> _varexpand_unexpected_eof_msg
> + if error_leader is
> not None:
> + msg =
> error_leader() + msg
> + writemsg(msg + "\n",
> noiselevel=-1)
> + return ""
> +
> braced = True
> else:
> braced = False
Yeah, good idea, looks good.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-04 6:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-04 6:01 [gentoo-portage-dev] [PATCH] varexpand: fix IndexError (bug 548556) Zac Medico
2015-05-04 6:22 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox