]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ita-comp-ima: Change validation URI parsing to avoid GCC 12 compiler warning
authorTobias Brunner <tobias@strongswan.org>
Thu, 16 Jun 2022 16:40:25 +0000 (18:40 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 27 Jun 2022 12:09:11 +0000 (14:09 +0200)
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.

src/libimcv/pts/components/ita/ita_comp_ima.c

index b1084e0af6df9efd74157e7d20852756d144d45e..2d2bcb1cdc0a19fceda3f091113737a3bbda15a5 100644 (file)
@@ -447,13 +447,11 @@ METHOD(pts_component_t, measure, status_t,
  * Parse a validation URI of the form <hash algorithm>:<event name>
  * 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)