summaryrefslogtreecommitdiff
path: root/source/os_specific/service_layers/oswinxf.c
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2011-05-17 14:07:44 -0700
committerRobert Moore <Robert.Moore@intel.com>2011-05-17 14:07:44 -0700
commitdcabd1cb73be336cac2178ffb5604e3d11288860 (patch)
tree5c79bd8b4b78cc98dc457800babe89cdb9a9efe4 /source/os_specific/service_layers/oswinxf.c
parentb0f371d61d77f9c555b5d2706938fff1c3af73a8 (diff)
downloadacpica-dcabd1cb73be336cac2178ffb5604e3d11288860.tar.gz
Debugger: Add max buffer length argument to AcpiOsGetLine.
Prevent buffer overflows. Also, now returns status. ACPICA BZ 920.
Diffstat (limited to 'source/os_specific/service_layers/oswinxf.c')
-rw-r--r--source/os_specific/service_layers/oswinxf.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c
index 1fb769699..8d20553a1 100644
--- a/source/os_specific/service_layers/oswinxf.c
+++ b/source/os_specific/service_layers/oswinxf.c
@@ -549,17 +549,21 @@ AcpiOsVprintf (
*
* FUNCTION: AcpiOsGetLine
*
- * PARAMETERS: Buffer - Where to store the line
+ * PARAMETERS: Buffer - Where to return the command line
+ * BufferLength - Maximum length of Buffer
+ * BytesRead - Where the actual byte count is returned
*
- * RETURN: Actual bytes read
+ * RETURN: Status and actual bytes read
*
* DESCRIPTION: Formatted input with argument list pointer
*
*****************************************************************************/
-UINT32
+ACPI_STATUS
AcpiOsGetLine (
- char *Buffer)
+ char *Buffer,
+ UINT32 BufferLength,
+ UINT32 *BytesRead)
{
char Temp;
UINT32 i;
@@ -567,6 +571,11 @@ AcpiOsGetLine (
for (i = 0; ; i++)
{
+ if (i >= BufferLength)
+ {
+ return (AE_BUFFER_OVERFLOW);
+ }
+
scanf ("%1c", &Temp);
if (!Temp || Temp == '\n')
{
@@ -582,7 +591,11 @@ AcpiOsGetLine (
/* Return the number of bytes in the string */
- return (i);
+ if (BytesRead)
+ {
+ *BytesRead = i;
+ }
+ return (AE_OK);
}