summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-03-30 15:51:46 +1100
committerChris Johns <chrisj@rtems.org>2016-03-31 14:45:59 +1100
commit0a2f5bdd190992ba16c147453d39461009810ae8 (patch)
treed6cc61fd55081cc11f50c9972a0ac4340e483f56
parentv850/gdbv850sim/include/bsp.h: Do not include <rtems/iosupp.h> (diff)
downloadrtems-0a2f5bdd190992ba16c147453d39461009810ae8.tar.bz2
bsp/pc386: Fix --console=/--printk= argument parsing.
-rw-r--r--c/src/lib/libbsp/i386/pc386/console/console_select.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/console/console_select.c b/c/src/lib/libbsp/i386/pc386/console/console_select.c
index 3fb31ecb3c..6a91a96083 100644
--- a/c/src/lib/libbsp/i386/pc386/console/console_select.c
+++ b/c/src/lib/libbsp/i386/pc386/console/console_select.c
@@ -33,6 +33,8 @@
#include <crt.h>
#endif
+#include <bsp/bspimpl.h>
+
/*
* Forward prototype
*/
@@ -142,9 +144,12 @@ static bool parse_printk_or_console(
rtems_device_minor_number *minor_out
)
{
- static const char *opt;
- char working[64] = "";
- char *p;
+ static const char *opt;
+ const char *option;
+ const char *comma;
+ size_t length;
+ size_t index;
+ rtems_device_minor_number minor;
/*
* Check the command line for the type of mode the console is.
@@ -155,30 +160,43 @@ static bool parse_printk_or_console(
}
/*
- * bsp_cmdline_arg() returns pointer to a string. It may not be the
- * last string on the command line.
+ * Fine the length, there can be more command line visible.
*/
- strncpy( working, opt, sizeof(working) );
- p = strchr( working, ' ' );
- if ( p ) {
- *p = '\0';
+ length = 0;
+ while ((opt[length] != ' ') && (opt[length] != '\0')) {
+ ++length;
+ if (length > NAME_MAX) {
+ printk("invalid option (%s): too long\n", param);
+ return false;
+ }
}
- const char *comma;
- size_t length = NAME_MAX;
- rtems_device_minor_number minor;
- char *option = working;
-
/*
* Only match up to a comma or NULL
*/
- comma = strchr (option, ',');
+ index = 0;
+ while ((opt[index] != '=') && (index < length)) {
+ ++index;
+ }
+
+ if (opt[index] != '=') {
+ printk("invalid option (%s): no equals\n", param);
+ return false;
+ }
+
+ ++index;
+ option = &opt[index];
- if ( comma ) {
- length = comma - option;
+ while ((opt[index] != ',') && (index < length)) {
+ ++index;
}
- option += strnlen(param, 32);
+ if (opt[index] == ',')
+ comma = &opt[index];
+ else
+ comma = NULL;
+
+ length = &opt[index] - option;
if ( !bsp_find_console_entry( option, length, &minor ) ) {
return false;
@@ -186,10 +204,10 @@ static bool parse_printk_or_console(
*minor_out = minor;
if (comma) {
- console_tbl *conscfg;
+ console_tbl *conscfg = &Console_Configuration_Ports[minor];
+
+ option = comma + 1;
- comma += 1;
- conscfg = &Console_Configuration_Ports[minor];
if (strncmp (option, "115200", sizeof ("115200") - 1) == 0)
conscfg->pDeviceParams = (void *)115200;
else if (strncmp (option, "57600", sizeof ("57600") - 1) == 0)