[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [PYGRUB] Fix a few bounds violations in pygrub's command-line editor.



# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
# Node ID 14dc20d98ee1478ad17abcbb24ae6dec46521178
# Parent  72579f0cdaf7acaf722b366fbb9d3e0114028493
[PYGRUB] Fix a few bounds violations in pygrub's command-line editor.
Don't step off the end of the line, or delete characters that aren't there.

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
---
 tools/pygrub/src/pygrub |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff -r 72579f0cdaf7 -r 14dc20d98ee1 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Thu Nov 09 14:11:11 2006 +0000
+++ b/tools/pygrub/src/pygrub   Thu Nov 09 14:23:24 2006 +0000
@@ -113,17 +113,21 @@ class GrubLineEditor(curses.textpad.Text
         elif ch == curses.ascii.SOH:  # ^a
             self.pos = 0
         elif ch in (curses.ascii.STX,curses.KEY_LEFT):
-            self.pos -= 1
+            if self.pos > 0:
+                self.pos -= 1
         elif ch in (curses.ascii.BS,curses.KEY_BACKSPACE):
             if self.pos > 0:
                 self.pos -= 1
+                if self.pos < len(self.line):
+                    self.line.pop(self.pos)
+        elif ch == curses.ascii.EOT:                           # ^d
+            if self.pos < len(self.line):
                 self.line.pop(self.pos)
-        elif ch == curses.ascii.EOT:                           # ^d
-            self.line.pop(self.pos)
         elif ch == curses.ascii.ENQ:                           # ^e
             self.pos = len(self.line)
         elif ch in (curses.ascii.ACK, curses.KEY_RIGHT):
-            self.pos +=1
+            if self.pos < len(self.line):
+                self.pos +=1
         elif ch == curses.ascii.VT:                            # ^k
             self.line = self.line[:self.pos]
         else:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.