ita-comp-ima: Change validation URI parsing to avoid GCC 12 compiler warning
The compiler warned that a dangling pointer might be used because `name`, which is returned from the function via `ima_name`, might point into the locally determined `uri`. Determining the URI outside and passing it to the function fixes this.
This commit is contained in:
@@ -447,13 +447,11 @@ METHOD(pts_component_t, measure, status_t,
|
|||||||
* Parse a validation URI of the form <hash algorithm>:<event name>
|
* Parse a validation URI of the form <hash algorithm>:<event name>
|
||||||
* into its components
|
* into its components
|
||||||
*/
|
*/
|
||||||
static pts_meas_algorithms_t parse_validation_uri(pts_comp_evidence_t *evidence,
|
static pts_meas_algorithms_t parse_validation_uri(char *uri, char **ima_name,
|
||||||
char **ima_name, char **ima_algo, char *algo_buf)
|
char **ima_algo, char *algo_buf)
|
||||||
{
|
{
|
||||||
pts_meas_algorithms_t hash_algo;
|
pts_meas_algorithms_t hash_algo;
|
||||||
char *uri, *pos, *algo, *name;
|
char *pos, *algo, *name;
|
||||||
|
|
||||||
evidence->get_validation(evidence, &uri);
|
|
||||||
|
|
||||||
/* IMA-NG format? */
|
/* IMA-NG format? */
|
||||||
pos = strchr(uri, ':');
|
pos = strchr(uri, ':');
|
||||||
@@ -712,13 +710,14 @@ METHOD(pts_component_t, verify, status_t,
|
|||||||
PTS_ITA_QUALIFIER_TYPE_OS))
|
PTS_ITA_QUALIFIER_TYPE_OS))
|
||||||
{
|
{
|
||||||
int ima_count;
|
int ima_count;
|
||||||
char *ima_algo, *ima_name;
|
char *uri, *ima_algo, *ima_name;
|
||||||
char algo_buf[IMA_ALGO_LEN_MAX];
|
char algo_buf[IMA_ALGO_LEN_MAX];
|
||||||
uint8_t pcr_buffer[HASH_SIZE_SHA512];
|
uint8_t pcr_buffer[HASH_SIZE_SHA512];
|
||||||
chunk_t boot_aggregate;
|
chunk_t boot_aggregate;
|
||||||
pts_meas_algorithms_t hash_algo;
|
pts_meas_algorithms_t hash_algo;
|
||||||
|
|
||||||
hash_algo = parse_validation_uri(evidence, &ima_name, &ima_algo,
|
evidence->get_validation(evidence, &uri);
|
||||||
|
hash_algo = parse_validation_uri(uri, &ima_name, &ima_algo,
|
||||||
algo_buf);
|
algo_buf);
|
||||||
|
|
||||||
switch (this->state)
|
switch (this->state)
|
||||||
|
|||||||
Reference in New Issue
Block a user