changeset 1325:921f9882bd6d

* 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.
author asl
date Tue, 21 Oct 2003 18:53:27 +0000
parents f5a5cdd6afe0
children 80fa78c1b074
files packages/net/httpd/current/ChangeLog packages/net/httpd/current/src/monitor.c
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/httpd/current/ChangeLog
+++ b/packages/net/httpd/current/ChangeLog
@@ -1,3 +1,11 @@
+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.
@@ -61,4 +69,3 @@ 2002-12-06  Nick Garnett  <nickg@ecoscen
 #
 # Permission is granted to use, copy, modify and redistribute this
 # file.
-		
--- a/packages/net/httpd/current/src/monitor.c
+++ b/packages/net/httpd/current/src/monitor.c
@@ -551,13 +551,21 @@ static cyg_bool cyg_monitor_memory( FILE
     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" );
 
@@ -588,6 +596,9 @@ static cyg_bool cyg_monitor_memory( FILE
                     "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, "" );
@@ -615,7 +626,8 @@ static cyg_bool cyg_monitor_memory( FILE
             cyg_html_tag_begin( client, "font", "face=\"monospace\"" );
             
             html_table_begin( client, "" );
-            {
+
+            if (valid_base == true) {
                 cyg_addrword_t loc;
                 cyg_addrword_t oloc;