summaryrefslogtreecommitdiff
path: root/drivers/acpi/acpica/utnonansi.c
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2018-01-05 00:41:27 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-01-05 03:33:22 +0300
commitee68d4773ed36e3f79860bbcad0a4ddd8d58f393 (patch)
tree5dd69e007decde8a5ca37b22a59f9b21a293333a /drivers/acpi/acpica/utnonansi.c
parent2cb0ba70fbbf36f34c2c31fabe19a267ac4a14a3 (diff)
downloadlinux-ee68d4773ed36e3f79860bbcad0a4ddd8d58f393.tar.xz
ACPICA: Create and deploy safe version of strncpy
ACPICA commit 64ad9c69a1bd534a466e060a33c0bbf5fc9e189c acpi_ut_safe_strncpy - copy and terminate string. Strncpy is not guaranteed to terminate the copied string if the input is longer than the length of the target. No functional change. Link: https://github.com/acpica/acpica/commit/64ad9c69 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Erik Schmauss <erik.schmauss@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/utnonansi.c')
-rw-r--r--drivers/acpi/acpica/utnonansi.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c
index 792664982ea3..33a0970646df 100644
--- a/drivers/acpi/acpica/utnonansi.c
+++ b/drivers/acpi/acpica/utnonansi.c
@@ -140,7 +140,7 @@ int acpi_ut_stricmp(char *string1, char *string2)
return (c1 - c2);
}
-#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION)
+#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) || defined (ACPI_DEBUG_OUTPUT)
/*******************************************************************************
*
* FUNCTION: acpi_ut_safe_strcpy, acpi_ut_safe_strcat, acpi_ut_safe_strncat
@@ -199,4 +199,13 @@ acpi_ut_safe_strncat(char *dest,
strncat(dest, source, max_transfer_length);
return (FALSE);
}
+
+void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size)
+{
+ /* Always terminate destination string */
+
+ strncpy(dest, source, dest_size);
+ dest[dest_size - 1] = 0;
+}
+
#endif