summaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-02-28 16:24:50 -0600
committerKent Yoder <key@linux.vnet.ibm.com>2013-04-12 12:17:28 -0500
commite361200bfc3b72de8db246de209da55d6d60fd34 (patch)
tree463b2b5295fde04a24daf82054e8cb0b16243f23 /drivers/char/tpm
parent2d089f82aeb59fd58f33f2bbf4288e4049426e17 (diff)
downloadlinux-e361200bfc3b72de8db246de209da55d6d60fd34.tar.bz2
drivers/char/tpm/tpm_ppi: use strlcpy instead of strncpy
Ensure that the 'version' string includes a NULL terminator after its copied out of the acpi table. Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm_ppi.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index 720ebcf29fdf..2168d15bc728 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -158,9 +158,9 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
ACPI_TYPE_STRING);
if (ACPI_FAILURE(status))
return -ENOMEM;
- strncpy(version,
+ strlcpy(version,
((union acpi_object *)output.pointer)->string.pointer,
- PPI_VERSION_LEN);
+ PPI_VERSION_LEN + 1);
kfree(output.pointer);
output.length = ACPI_ALLOCATE_BUFFER;
output.pointer = NULL;
@@ -237,9 +237,9 @@ static ssize_t tpm_show_ppi_transition_action(struct device *dev,
ACPI_TYPE_STRING);
if (ACPI_FAILURE(status))
return -ENOMEM;
- strncpy(version,
+ strlcpy(version,
((union acpi_object *)output.pointer)->string.pointer,
- PPI_VERSION_LEN);
+ PPI_VERSION_LEN + 1);
/*
* PPI spec defines params[3].type as empty package, but some platforms
* (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for
@@ -351,7 +351,7 @@ cleanup:
static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
{
char *str = buf;
- char version[PPI_VERSION_LEN];
+ char version[PPI_VERSION_LEN + 1];
acpi_handle handle;
acpi_status status;
struct acpi_object_list input;
@@ -381,9 +381,9 @@ static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
if (ACPI_FAILURE(status))
return -ENOMEM;
- strncpy(version,
+ strlcpy(version,
((union acpi_object *)output.pointer)->string.pointer,
- PPI_VERSION_LEN);
+ PPI_VERSION_LEN + 1);
kfree(output.pointer);
output.length = ACPI_ALLOCATE_BUFFER;
output.pointer = NULL;