diff options
author | Chen Gang <gang.chen@asianux.com> | 2013-02-28 17:24:50 -0500 |
---|---|---|
committer | Kent Yoder <key@linux.vnet.ibm.com> | 2013-04-12 13:17:28 -0400 |
commit | e361200bfc3b72de8db246de209da55d6d60fd34 (patch) | |
tree | 463b2b5295fde04a24daf82054e8cb0b16243f23 | |
parent | 2d089f82aeb59fd58f33f2bbf4288e4049426e17 (diff) |
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>
-rw-r--r-- | drivers/char/tpm/tpm_ppi.c | 14 |
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, | |||
158 | ACPI_TYPE_STRING); | 158 | ACPI_TYPE_STRING); |
159 | if (ACPI_FAILURE(status)) | 159 | if (ACPI_FAILURE(status)) |
160 | return -ENOMEM; | 160 | return -ENOMEM; |
161 | strncpy(version, | 161 | strlcpy(version, |
162 | ((union acpi_object *)output.pointer)->string.pointer, | 162 | ((union acpi_object *)output.pointer)->string.pointer, |
163 | PPI_VERSION_LEN); | 163 | PPI_VERSION_LEN + 1); |
164 | kfree(output.pointer); | 164 | kfree(output.pointer); |
165 | output.length = ACPI_ALLOCATE_BUFFER; | 165 | output.length = ACPI_ALLOCATE_BUFFER; |
166 | output.pointer = NULL; | 166 | output.pointer = NULL; |
@@ -237,9 +237,9 @@ static ssize_t tpm_show_ppi_transition_action(struct device *dev, | |||
237 | ACPI_TYPE_STRING); | 237 | ACPI_TYPE_STRING); |
238 | if (ACPI_FAILURE(status)) | 238 | if (ACPI_FAILURE(status)) |
239 | return -ENOMEM; | 239 | return -ENOMEM; |
240 | strncpy(version, | 240 | strlcpy(version, |
241 | ((union acpi_object *)output.pointer)->string.pointer, | 241 | ((union acpi_object *)output.pointer)->string.pointer, |
242 | PPI_VERSION_LEN); | 242 | PPI_VERSION_LEN + 1); |
243 | /* | 243 | /* |
244 | * PPI spec defines params[3].type as empty package, but some platforms | 244 | * PPI spec defines params[3].type as empty package, but some platforms |
245 | * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for | 245 | * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for |
@@ -351,7 +351,7 @@ cleanup: | |||
351 | static ssize_t show_ppi_operations(char *buf, u32 start, u32 end) | 351 | static ssize_t show_ppi_operations(char *buf, u32 start, u32 end) |
352 | { | 352 | { |
353 | char *str = buf; | 353 | char *str = buf; |
354 | char version[PPI_VERSION_LEN]; | 354 | char version[PPI_VERSION_LEN + 1]; |
355 | acpi_handle handle; | 355 | acpi_handle handle; |
356 | acpi_status status; | 356 | acpi_status status; |
357 | struct acpi_object_list input; | 357 | struct acpi_object_list input; |
@@ -381,9 +381,9 @@ static ssize_t show_ppi_operations(char *buf, u32 start, u32 end) | |||
381 | if (ACPI_FAILURE(status)) | 381 | if (ACPI_FAILURE(status)) |
382 | return -ENOMEM; | 382 | return -ENOMEM; |
383 | 383 | ||
384 | strncpy(version, | 384 | strlcpy(version, |
385 | ((union acpi_object *)output.pointer)->string.pointer, | 385 | ((union acpi_object *)output.pointer)->string.pointer, |
386 | PPI_VERSION_LEN); | 386 | PPI_VERSION_LEN + 1); |
387 | kfree(output.pointer); | 387 | kfree(output.pointer); |
388 | output.length = ACPI_ALLOCATE_BUFFER; | 388 | output.length = ACPI_ALLOCATE_BUFFER; |
389 | output.pointer = NULL; | 389 | output.pointer = NULL; |