[PATCH ima-evm-utils v1 3/4] Add assert to ensure that algo_name in bank is set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To avoid numerous warning messages from gcc 12.2.1 when compiling with
-fanalyzer, insert an assert to ensure that algo_name in each bank
is set. The assert resolves the following warnings:

evmctl.c:1998:30: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
 1998 |                         if (!strcmp(tpm_banks[j].algo_name, alg)) {
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

evmctl.c: In function ‘ima_measurement’:
evmctl.c:2146:24: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
 2146 |                     && strcmp(pseudo_padded_banks[c].algo_name, verify_bank)) {
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ‘ima_measurement’: events 1-2

evmctl.c: In function ‘cmd_ima_bootaggr’:
evmctl.c:2611:33: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
 2611 |                 bootaggr_len += strlen(tpm_banks[i].algo_name) + 1;
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxx>
---
 src/evmctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/evmctl.c b/src/evmctl.c
index 4afc265..4f55fb6 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1723,6 +1723,7 @@ static struct tpm_bank_info *init_tpm_banks(int *num_banks)
 			if (!strcmp(default_algos[i], hash_algo_name[j]))
 				set_bank_info(&banks[i], hash_algo_name[j]);
 		}
+		assert(banks[i].algo_name);
 	}
 	return banks;
 }
-- 
2.38.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux