This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for httpd monitor


The simple monitor example daemon that comes with the httpd stuff
can display memory contents as a hex dump. The address is specified
with the 'base' parameter; however when the page is accessed without
this parameter (as when the user clicks on the link from the
monitor.html page), an address of zero is assumed, which will crash
targets where address zero is not valid (mine, for example) before
the user can even choose which address range to dump.

The attached patch does a quick fix by not dumping any data if 'base'
is not specified in the HTTP request. A better solution would be to
ask the HAL if an address range is accessible; unfortunately no such
HAL functionality exists. There is a CYG_HAL_STUB_PERMIT_DATA_READ(),
but this macro seems to be only intended for use with the GDB stub and
does not seem to actually do anything on mose platforms, even if a
MMU is available that could be queried.
--
--------------------------------------------------------------------
|     Eric Doenges              |     DynaPel Laboratories GmbH    |
|     Tel: +49 89 962428 23     |     Fraunhoferstrasse 9/2        |
|     Fax: +49 89 962428 90     |     D - 85737 Ismaning, Germany  |
--------------------------------------------------------------------
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/httpd/current/ChangeLog,v
retrieving revision 1.8
diff -u -5 -b -r1.8 ChangeLog
--- ChangeLog	23 Sep 2003 11:40:14 -0000	1.8
+++ ChangeLog	21 Oct 2003 13:28:18 -0000
@@ -1,5 +1,13 @@
+2003-10-21  Eric Doenges <Eric.Doenges@DynaPel.com>
+
+	* src/monitor.c (cyg_monitor_memory): Check if the request
+	contains a 'base' parameter and don't display anything if it does
+	not. This prevents the monitor from attempting to access memory
+	location '0' when the user accesses the memory html page for the
+	first time without any parameters.
+
 2003-09-23  Andrew Lunn  <andrew.lunn@ascom.ch>
 
         * src/httpd.c (cyg_httpd_server): Removed unused variable.
         * doc/httpd.sgml: Updated documentation for previous change.
 
@@ -59,6 +67,5 @@
 # Copyright (C) 2002 Nick Garnett
 # All Rights Reserved.
 #
 # Permission is granted to use, copy, modify and redistribute this
 # file.
-		
Index: src/httpd.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/httpd/current/src/httpd.c,v
retrieving revision 1.4
diff -u -5 -b -r1.4 httpd.c
Index: src/monitor.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/httpd/current/src/monitor.c,v
retrieving revision 1.4
diff -u -5 -b -r1.4 monitor.c
--- src/monitor.c	14 Jun 2003 18:04:55 -0000	1.4
+++ src/monitor.c	21 Oct 2003 13:28:20 -0000
@@ -549,17 +549,25 @@
     char *formlist[10];
     cyg_uint32 base = 0;
     unsigned int datasize = 1;
     int size = 256;
     char *p;
+    bool valid_base = true;
+
     
     cyg_formdata_parse( formdata, formlist, 10 );
 
     p = cyg_formlist_find( formlist, "base" );
 
+    /* If the page is requested without a 'base' parameter, do not attempt
+     * to access any memory locations to prevent illegal memory accesses
+     * on targets where '0' is not a valid address.
+     */
     if( p != NULL )
         sscanf( p, "%x", &base );
+    else
+        valid_base = false;
 
     p = cyg_formlist_find( formlist, "datasize" );
 
     if( p != NULL )
         sscanf( p, "%x", &datasize );
@@ -586,10 +594,13 @@
             html_para_begin( client, "" );
             fprintf(client,
                     "Base Address: 0x<input type=\"text\" name=\"base\" size=\"10\" value=\"%x\">\n",
                     base);
 
+            fprintf(client,
+                    "WARNING: entering an illegal base address can crash the system.\n");
+
             /* A little menu for the element size
              */
             html_para_begin( client, "" );
 
             fputs( "Element Size: ", client );
@@ -613,11 +624,12 @@
 
             /* Switch to monospaced font */
             cyg_html_tag_begin( client, "font", "face=\"monospace\"" );
             
             html_table_begin( client, "" );
-            {
+
+            if (valid_base == true) {
                 cyg_addrword_t loc;
                 cyg_addrword_t oloc;
                 
                 for( oloc = loc = base; loc <= (base+size) ; loc++ )
                 {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]