mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
ima: Use snprintf() in create_securityfs_measurement_lists
Use the more secure snprintf() function (accepting the buffer size) in create_securityfs_measurement_lists(). No functional change: sprintf() and snprintf() have the same behavior. Link: https://github.com/linux-integrity/linux/issues/1 Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
parent
51bedcd803
commit
56275ec766
|
|
@ -503,11 +503,13 @@ static int __init create_securityfs_measurement_lists(void)
|
|||
struct dentry *dentry;
|
||||
|
||||
if (algo == HASH_ALGO__LAST)
|
||||
sprintf(file_name, "ascii_runtime_measurements_tpm_alg_%x",
|
||||
ima_tpm_chip->allocated_banks[i].alg_id);
|
||||
snprintf(file_name, sizeof(file_name),
|
||||
"ascii_runtime_measurements_tpm_alg_%x",
|
||||
ima_tpm_chip->allocated_banks[i].alg_id);
|
||||
else
|
||||
sprintf(file_name, "ascii_runtime_measurements_%s",
|
||||
hash_algo_name[algo]);
|
||||
snprintf(file_name, sizeof(file_name),
|
||||
"ascii_runtime_measurements_%s",
|
||||
hash_algo_name[algo]);
|
||||
dentry = securityfs_create_file(file_name, S_IRUSR | S_IRGRP,
|
||||
ima_dir, (void *)(uintptr_t)i,
|
||||
&ima_ascii_measurements_ops);
|
||||
|
|
@ -515,11 +517,13 @@ static int __init create_securityfs_measurement_lists(void)
|
|||
return PTR_ERR(dentry);
|
||||
|
||||
if (algo == HASH_ALGO__LAST)
|
||||
sprintf(file_name, "binary_runtime_measurements_tpm_alg_%x",
|
||||
ima_tpm_chip->allocated_banks[i].alg_id);
|
||||
snprintf(file_name, sizeof(file_name),
|
||||
"binary_runtime_measurements_tpm_alg_%x",
|
||||
ima_tpm_chip->allocated_banks[i].alg_id);
|
||||
else
|
||||
sprintf(file_name, "binary_runtime_measurements_%s",
|
||||
hash_algo_name[algo]);
|
||||
snprintf(file_name, sizeof(file_name),
|
||||
"binary_runtime_measurements_%s",
|
||||
hash_algo_name[algo]);
|
||||
dentry = securityfs_create_file(file_name, S_IRUSR | S_IRGRP,
|
||||
ima_dir, (void *)(uintptr_t)i,
|
||||
&ima_measurements_ops);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user