Skip to contentSkip to conversation

Coverity fixes for tools/firmware

PATCH In review Andrew Cooper 2 participants 4 messages Nov 25, 2013 – Nov 26, 2013

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 firmware/tcgbios: Prevent integer truncation in the return value

rc inside the function is uint32_t. None of the callers check the return value.

Coverity ID: 1055442

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
---
 tools/firmware/rombios/32bit/tcgbios/tcgbios.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/firmware/rombios/32bit/tcgbios/tcgbios.c +1 -1
index d5e2202..01d4f2f 100644
@@ -428,7 +428,7 @@ uint32_t tcpa_get_laml(void)
  *  data       : pointer to the data (i.e., string) to be added to the log
  *  length     : length of the data
  */
-static uint16_t
+static uint32_t
 tcpa_add_measurement_to_log(uint32_t pcrIndex,
                             uint32_t event_type,
                             uint32_t event_id,
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 2/2 firmware/vgabios: Fix incorrect formatting string

In reply to Andrew Cooper

bios_len is an long, so requires %ld rather than %d.

Coverity ID: 1055813

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
---
 tools/firmware/vgabios/biossums.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/firmware/vgabios/biossums.c +1 -1
index d5816f4..6288498 100644
@@ -161,7 +161,7 @@ int main(int argc, char* argv[])
       exit(EXIT_FAILURE);
     }
     if (fwrite(bios_data, 1, bios_len, stream) < bios_len) {
-      printf("Error writing %d KBytes to %s.\n", bios_len / 1024, argv[1]);
+      printf("Error writing %ld KBytes to %s.\n", bios_len / 1024, argv[1]);
       fclose(stream);
       exit(EXIT_FAILURE);
     }
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH 1/2] firmware/tcgbios: Prevent integer truncation in the return value

In reply to Andrew Cooper
Quoted 1 line · Andrew Cooper

rc inside the function is uint32_t. None of the callers check the return value.

Makes me wonder if chaigng to returning void might have been better, but any way, I acked and applied this and hte second one.

Quoted 25 lines

Coverity ID: 1055442

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
---
 tools/firmware/rombios/32bit/tcgbios/tcgbios.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/firmware/rombios/32bit/tcgbios/tcgbios.c +1 -1
index d5e2202..01d4f2f 100644
@@ -428,7 +428,7 @@ uint32_t tcpa_get_laml(void)
  *  data       : pointer to the data (i.e., string) to be added to the log
  *  length     : length of the data
  */
-static uint16_t
+static uint32_t
 tcpa_add_measurement_to_log(uint32_t pcrIndex,
                             uint32_t event_type,
                             uint32_t event_id,