diff options
Diffstat (limited to 'source/components/debugger')
-rw-r--r-- | source/components/debugger/dbexec.c | 44 | ||||
-rw-r--r-- | source/components/debugger/dbfileio.c | 2 | ||||
-rw-r--r-- | source/components/debugger/dbhistry.c | 35 | ||||
-rw-r--r-- | source/components/debugger/dbinput.c | 18 | ||||
-rw-r--r-- | source/components/debugger/dbnames.c | 20 | ||||
-rw-r--r-- | source/components/debugger/dbxface.c | 4 |
6 files changed, 104 insertions, 19 deletions
diff --git a/source/components/debugger/dbexec.c b/source/components/debugger/dbexec.c index dff3c79..668dcdd 100644 --- a/source/components/debugger/dbexec.c +++ b/source/components/debugger/dbexec.c @@ -62,7 +62,7 @@ AcpiDbExecuteMethod ( ACPI_DB_METHOD_INFO *Info, ACPI_BUFFER *ReturnObj); -static void +static ACPI_STATUS AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info); @@ -237,10 +237,15 @@ Cleanup: * ******************************************************************************/ -static void +static ACPI_STATUS AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info) { + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (DbExecuteSetup); + /* Catenate the current scope to the supplied name */ @@ -248,10 +253,21 @@ AcpiDbExecuteSetup ( if ((Info->Name[0] != '\\') && (Info->Name[0] != '/')) { - ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); + if (AcpiUtSafeStrcat (Info->Pathname, sizeof (Info->Pathname), + AcpiGbl_DbScopeBuf)) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; + } + } + + if (AcpiUtSafeStrcat (Info->Pathname, sizeof (Info->Pathname), + Info->Name)) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; } - ACPI_STRCAT (Info->Pathname, Info->Name); AcpiDbPrepNamestring (Info->Pathname); AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); @@ -269,6 +285,13 @@ AcpiDbExecuteSetup ( AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); } + + return (AE_OK); + +ErrorExit: + + ACPI_EXCEPTION ((AE_INFO, Status, "During setup for method execution")); + return (Status); } @@ -429,7 +452,12 @@ AcpiDbExecute ( ReturnObj.Pointer = NULL; ReturnObj.Length = ACPI_ALLOCATE_BUFFER; - AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + Status = AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (NameString); + return; + } /* Get the NS node, determines existence also */ @@ -729,7 +757,11 @@ AcpiDbCreateExecutionThreads ( AcpiDbUint32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); - AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + Status = AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + if (ACPI_FAILURE (Status)) + { + goto CleanupAndExit; + } /* Get the NS node, determines existence also */ diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index 3ba9653..373e7ad 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -492,7 +492,7 @@ AcpiDbReadTableFromFile ( File = fopen (Filename, "rb"); if (!File) { - AcpiOsPrintf ("Could not open input file %s\n", Filename); + perror ("Could not open input file"); return (AE_ERROR); } diff --git a/source/components/debugger/dbhistry.c b/source/components/debugger/dbhistry.c index ff11604..2daa01f 100644 --- a/source/components/debugger/dbhistry.c +++ b/source/components/debugger/dbhistry.c @@ -69,7 +69,7 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; static UINT16 AcpiGbl_LoHistory = 0; static UINT16 AcpiGbl_NumHistory = 0; static UINT16 AcpiGbl_NextHistoryIndex = 0; -static UINT32 AcpiGbl_NextCmdNum = 1; +UINT32 AcpiGbl_NextCmdNum = 1; /******************************************************************************* @@ -94,6 +94,11 @@ AcpiDbAddToHistory ( /* Put command into the next available slot */ CmdLen = (UINT16) ACPI_STRLEN (CommandLine); + if (!CmdLen) + { + return; + } + if (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command != NULL) { BufferLen = (UINT16) ACPI_STRLEN ( @@ -203,8 +208,6 @@ char * AcpiDbGetFromHistory ( char *CommandNumArg) { - UINT32 i; - UINT16 HistoryIndex; UINT32 CmdNum; @@ -218,6 +221,31 @@ AcpiDbGetFromHistory ( CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); } + return (AcpiDbGetHistoryByIndex (CmdNum)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetHistoryByIndex + * + * PARAMETERS: CmdNum - Index of the desired history entry. + * Values are 0...(AcpiGbl_NextCmdNum - 1) + * + * RETURN: Pointer to the retrieved command. Null on error. + * + * DESCRIPTION: Get a command from the history buffer + * + ******************************************************************************/ + +char * +AcpiDbGetHistoryByIndex ( + UINT32 CmdNum) +{ + UINT32 i; + UINT16 HistoryIndex; + + /* Search history buffer */ HistoryIndex = AcpiGbl_LoHistory; @@ -230,6 +258,7 @@ AcpiDbGetFromHistory ( return (AcpiGbl_HistoryBuffer[HistoryIndex].Command); } + /* History buffer is circular */ HistoryIndex++; if (HistoryIndex >= HISTORY_SIZE) diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index 511e585..147a023 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -635,7 +635,13 @@ AcpiDbGetLine ( char *This; - ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); + if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf), + InputBuffer)) + { + AcpiOsPrintf ("Buffer overflow while parsing input line (max %u characters)\n", + sizeof (AcpiGbl_DbParsedBuf)); + return (0); + } This = AcpiGbl_DbParsedBuf; for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) @@ -740,6 +746,11 @@ AcpiDbCommandDispatch ( return (AE_CTRL_TERMINATE); } + + /* Add all commands that come here to the history buffer */ + + AcpiDbAddToHistory (InputBuffer); + ParamCount = AcpiDbGetLine (InputBuffer); CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); Temp = 0; @@ -1135,7 +1146,7 @@ AcpiDbCommandDispatch ( case CMD_NOT_FOUND: default: - AcpiOsPrintf ("Unknown Command\n"); + AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]); return (AE_CTRL_TRUE); } @@ -1144,9 +1155,6 @@ AcpiDbCommandDispatch ( Status = AE_CTRL_TRUE; } - /* Add all commands that come here to the history buffer */ - - AcpiDbAddToHistory (InputBuffer); return (Status); } diff --git a/source/components/debugger/dbnames.c b/source/components/debugger/dbnames.c index e3c6d71..c071289 100644 --- a/source/components/debugger/dbnames.c +++ b/source/components/debugger/dbnames.c @@ -171,8 +171,7 @@ AcpiDbSetScope ( goto ErrorExit; } - ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); - ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + AcpiGbl_DbScopeBuf[0] = 0; } else { @@ -184,9 +183,22 @@ AcpiDbSetScope ( { goto ErrorExit; } + } + + /* Build the final pathname */ + + if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), + Name)) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; + } - ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); - ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), + "\\")) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; } AcpiGbl_DbScopeNode = Node; diff --git a/source/components/debugger/dbxface.c b/source/components/debugger/dbxface.c index 3c1df5b..eedff1f 100644 --- a/source/components/debugger/dbxface.c +++ b/source/components/debugger/dbxface.c @@ -507,6 +507,10 @@ AcpiDbTerminate ( AcpiOsFree (AcpiGbl_DbBuffer); AcpiGbl_DbBuffer = NULL; } + + /* Ensure that debug output is now disabled */ + + AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT; } |