From: Tobias Brunner Date: Thu, 16 Jun 2022 16:40:25 +0000 (+0200) Subject: ita-comp-ima: Change validation URI parsing to avoid GCC 12 compiler warning X-Git-Tag: 5.9.7dr2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a19a5e056eac2c0cb11fb2ec321a1530390bc78;p=thirdparty%2Fstrongswan.git 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. --- diff --git a/src/libimcv/pts/components/ita/ita_comp_ima.c b/src/libimcv/pts/components/ita/ita_comp_ima.c index b1084e0af6..2d2bcb1cdc 100644 --- a/src/libimcv/pts/components/ita/ita_comp_ima.c +++ b/src/libimcv/pts/components/ita/ita_comp_ima.c @@ -447,13 +447,11 @@ METHOD(pts_component_t, measure, status_t, * Parse a validation URI of the form : * into its components */ -static pts_meas_algorithms_t parse_validation_uri(pts_comp_evidence_t *evidence, - char **ima_name, char **ima_algo, char *algo_buf) +static pts_meas_algorithms_t parse_validation_uri(char *uri, char **ima_name, + char **ima_algo, char *algo_buf) { pts_meas_algorithms_t hash_algo; - char *uri, *pos, *algo, *name; - - evidence->get_validation(evidence, &uri); + char *pos, *algo, *name; /* IMA-NG format? */ pos = strchr(uri, ':'); @@ -712,13 +710,14 @@ METHOD(pts_component_t, verify, status_t, PTS_ITA_QUALIFIER_TYPE_OS)) { int ima_count; - char *ima_algo, *ima_name; + char *uri, *ima_algo, *ima_name; char algo_buf[IMA_ALGO_LEN_MAX]; uint8_t pcr_buffer[HASH_SIZE_SHA512]; chunk_t boot_aggregate; 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); switch (this->state)