WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4 of 7] minios: fix minios console

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 4 of 7] minios: fix minios console
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Mon, 12 Oct 2009 18:20:28 +0100
Delivery-date: Mon, 12 Oct 2009 10:22:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
MiniOS' console_print tries to expand '\n' into "\n\r" in place, causing
page faults if the string resides in text.
Use a duplicate of the string instead.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---

diff -r 21935dfa8e5f extras/mini-os/console/console.c
--- a/extras/mini-os/console/console.c  Fri Oct 09 19:30:39 2009 +0100
+++ b/extras/mini-os/console/console.c  Mon Oct 12 16:03:49 2009 +0100
@@ -79,6 +79,8 @@
 void console_print(struct consfront_dev *dev, char *data, int length)
 {
     char *curr_char, saved_char;
+    char copied_str[length];
+    char *copied_ptr;
     int part_len;
     int (*ring_send_fn)(struct consfront_dev *dev, const char *data, unsigned 
length);
 
@@ -86,24 +88,26 @@
         ring_send_fn = xencons_ring_send_no_notify;
     else
         ring_send_fn = xencons_ring_send;
-        
-    for(curr_char = data; curr_char < data+length-1; curr_char++)
+
+    copied_ptr = copied_str;
+    memcpy(copied_ptr, data, length);
+    for(curr_char = copied_ptr; curr_char < copied_ptr+length-1; curr_char++)
     {
         if(*curr_char == '\n')
         {
             saved_char = *(curr_char+1);
             *(curr_char+1) = '\r';
-            part_len = curr_char - data + 2;
-            ring_send_fn(dev, data, part_len);
+            part_len = curr_char - copied_ptr + 2;
+            ring_send_fn(dev, copied_ptr, part_len);
             *(curr_char+1) = saved_char;
-            data = curr_char+1;
+            copied_ptr = curr_char+1;
             length -= part_len - 1;
         }
     }
     
-    ring_send_fn(dev, data, length);
+    ring_send_fn(dev, copied_ptr, length);
     
-    if(data[length-1] == '\n')
+    if(copied_ptr[length-1] == '\n')
         ring_send_fn(dev, "\r", 1);
 }
 

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

<Prev in Thread] Current Thread [Next in Thread>