From b857151112fe5ae05f20447e2598123a3bce1657 Mon Sep 17 00:00:00 2001 From: Hermann Felbinger Date: Sat, 26 Aug 2017 09:15:52 +0100 Subject: covoar: Fix buffer overflow and fix br tag in html report. Co-Author: Krzysztof Miesowicz --- tester/covoar/ReportsBase.cc | 11 ++++++----- tester/covoar/ReportsHtml.cc | 46 ++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index b61fc76..01950d0 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -210,10 +210,11 @@ void ReportsBase::WriteAnnotatedReport( itr != theInstructions->end(); itr++ ) { - uint32_t id = 0; - std::string annotation = ""; - std::string line; - char textLine[150]; + uint32_t id = 0; + std::string annotation = ""; + std::string line; + const std::size_t LINE_LENGTH = 150; + char textLine[LINE_LENGTH]; state = A_SOURCE; @@ -236,7 +237,7 @@ void ReportsBase::WriteAnnotatedReport( } } - sprintf( textLine, "%-70s", itr->line.c_str() ); + snprintf( textLine, LINE_LENGTH, "%-70s", itr->line.c_str() ); line = textLine + annotation; PutAnnotatedLine( aFile, state, line, id); diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc index 101c76b..247253c 100644 --- a/tester/covoar/ReportsHtml.cc +++ b/tester/covoar/ReportsHtml.cc @@ -52,7 +52,7 @@ namespace Coverage { #define PRINT_TEXT_ITEM( _t, _n ) \ fprintf( \ aFile, \ - "
  • %s (text)\n", \ + "
  • %s (text)
  • \n", \ _t, _n ); FILE* aFile; @@ -69,7 +69,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -93,7 +93,7 @@ namespace Coverage { fprintf( aFile, - "\n" + "\n" "\n" "\n" ); @@ -144,7 +144,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -181,7 +181,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -197,7 +197,7 @@ namespace Coverage { "Symbol\n" "Line\n" "File\n" - "Size
    Bytes\n" + "Size
    Bytes\n" "Reason\n" "Taken\n" "Not Taken\n" @@ -232,7 +232,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -248,8 +248,8 @@ namespace Coverage { "Symbol\n" "Range\n" "File\n" - "Size
    Bytes\n" - "Size
    Instructions\n" + "Size
    Bytes\n" + "Size
    Instructions\n" "Classification\n" "Explanation\n" "\n" @@ -281,7 +281,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -326,7 +326,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -371,7 +371,7 @@ namespace Coverage { if (projectName) fprintf( aFile, - "%s
    ", + "%s
    ", projectName ); @@ -385,16 +385,16 @@ namespace Coverage { "\n" "\n" "Symbol\n" - "Total
    Size
    Bytes\n" - "Total
    Size
    Instr\n" - "#
    Ranges\n" - "Uncovered
    Size
    Bytes\n" - "Uncovered
    Size
    Instr\n" - "#
    Branches\n" - "#
    Always
    Taken\n" - "#
    Never
    Taken\n" - "Percent
    Uncovered
    Instructions\n" - "Percent
    Uncovered
    Bytes\n" + "Total
    Size
    Bytes\n" + "Total
    Size
    Instr\n" + "#
    Ranges\n" + "Uncovered
    Size
    Bytes\n" + "Uncovered
    Size
    Instr\n" + "#
    Branches\n" + "#
    Always
    Taken\n" + "#
    Never
    Taken\n" + "Percent
    Uncovered
    Instructions\n" + "Percent
    Uncovered
    Bytes\n" "\n" "\n" "\n", @@ -728,7 +728,7 @@ namespace Coverage { // Range fprintf( report, - "%s
    %s\n", + "
    %s
    %s\n", rangePtr->id, rangePtr->lowSourceLine.c_str(), rangePtr->highSourceLine.c_str() -- cgit v1.2.3