mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-04-27 14:22:31 +02:00
Don't ignore number of items read
fread() either returns the number of bytes read or the number of items of data read. Check that it returns the requested number of items read. Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
parent
c8b1757270
commit
6778e3511b
12
src/evmctl.c
12
src/evmctl.c
@ -2161,7 +2161,7 @@ static int ima_measurement(const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(entry.name, 0x00, sizeof(entry.name));
|
memset(entry.name, 0x00, sizeof(entry.name));
|
||||||
if (!fread(entry.name, entry.header.name_len, 1, fp)) {
|
if (fread(entry.name, entry.header.name_len, 1, fp) != 1) {
|
||||||
log_err("Unable to read template name\n");
|
log_err("Unable to read template name\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -2184,8 +2184,8 @@ static int ima_measurement(const char *file)
|
|||||||
|
|
||||||
/* The "ima" template data is not length prefixed. Skip it. */
|
/* The "ima" template data is not length prefixed. Skip it. */
|
||||||
if (!is_ima_template) {
|
if (!is_ima_template) {
|
||||||
if (!fread(&entry.template_len,
|
if (fread(&entry.template_len,
|
||||||
sizeof(entry.template_len), 1, fp)) {
|
sizeof(entry.template_len), 1, fp) != 1) {
|
||||||
log_err("Unable to read template length\n");
|
log_err("Unable to read template length\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -2205,7 +2205,8 @@ static int ima_measurement(const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is_ima_template) {
|
if (!is_ima_template) {
|
||||||
if (!fread(entry.template, entry.template_len, 1, fp)) {
|
if (fread(entry.template, entry.template_len,
|
||||||
|
1, fp) != 1) {
|
||||||
log_errno("Unable to read template\n");
|
log_errno("Unable to read template\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -2217,7 +2218,8 @@ static int ima_measurement(const char *file)
|
|||||||
* The "ima" template data format is digest,
|
* The "ima" template data format is digest,
|
||||||
* filename length, filename.
|
* filename length, filename.
|
||||||
*/
|
*/
|
||||||
if (!fread(entry.template, SHA_DIGEST_LENGTH, 1, fp)) {
|
if (fread(entry.template, SHA_DIGEST_LENGTH,
|
||||||
|
1, fp) != 1) {
|
||||||
log_errno("Unable to read file data hash\n");
|
log_errno("Unable to read file data hash\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user