[PATCH v2 3/9] covoar: Fix buffer overflow and fix br tag in html report.
Cillian O'Donnell
cpodonnell8 at gmail.com
Sat Aug 26 08:15:52 UTC 2017
From: Hermann Felbinger <hermann19829 at gmail.com>
Co-Author: Krzysztof Miesowicz <krzysztof.miesowicz at gmail.com>
---
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, \
- "<li>%s (<a href=\"%s\">text</a>)\n", \
+ "<li>%s (<a href=\"%s\">text</a>)</li>\n", \
_t, _n );
FILE* aFile;
@@ -69,7 +69,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -93,7 +93,7 @@ namespace Coverage {
fprintf(
aFile,
- "</li>\n"
+ "</ul>\n"
"<!-- INSERT PROJECT SPECIFIC ITEMS HERE -->\n"
"</html>\n"
);
@@ -144,7 +144,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -181,7 +181,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -197,7 +197,7 @@ namespace Coverage {
"<th class=\"table-sortable:default\" align=\"left\">Symbol</th>\n"
"<th class=\"table-sortable:default\" align=\"left\">Line</th>\n"
"<th class=\"table-filterable table-sortable:default\" align=\"left\">File</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"left\">Size </br>Bytes</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"left\">Size <br>Bytes</th>\n"
"<th class=\"table-sortable:default\" align=\"left\">Reason</th>\n"
"<th class=\"table-filterable table-sortable:default\" align=\"left\">Taken</th>\n"
"<th class=\"table-filterable table-sortable:default\" align=\"left\">Not Taken</th>\n"
@@ -232,7 +232,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -248,8 +248,8 @@ namespace Coverage {
"<th class=\"table-sortable:default\" align=\"left\">Symbol</th>\n"
"<th class=\"table-sortable:default\" align=\"left\">Range</th>\n"
"<th class=\"table-filterable table-sortable:default\" align=\"left\">File</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"left\">Size </br>Bytes</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"left\">Size </br>Instructions</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"left\">Size <br>Bytes</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"left\">Size <br>Instructions</th>\n"
"<th class=\"table-filterable table-sortable:default\" align=\"left\">Classification</th>\n"
"<th class=\"table-sortable:default\" align=\"left\">Explanation</th>\n"
"</tr>\n"
@@ -281,7 +281,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -326,7 +326,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -371,7 +371,7 @@ namespace Coverage {
if (projectName)
fprintf(
aFile,
- "%s</br>",
+ "%s<br>",
projectName
);
@@ -385,16 +385,16 @@ namespace Coverage {
"<thead>\n"
"<tr>\n"
"<th class=\"table-sortable:default\" align=\"center\">Symbol</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">Total</br>Size</br>Bytes</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">Total</br>Size</br>Instr</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">#</br>Ranges</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">Uncovered</br>Size</br>Bytes</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">Uncovered</br>Size</br>Instr</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">#</br>Branches</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">#</br>Always</br>Taken</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">#</br>Never</br>Taken</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">Percent</br>Uncovered</br>Instructions</th>\n"
- "<th class=\"table-sortable:numeric\" align=\"center\">Percent</br>Uncovered</br>Bytes</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">Total<br>Size<br>Bytes</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">Total<br>Size<br>Instr</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">#<br>Ranges</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">Uncovered<br>Size<br>Bytes</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">Uncovered<br>Size<br>Instr</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">#<br>Branches</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">#<br>Always<br>Taken</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">#<br>Never<br>Taken</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">Percent<br>Uncovered<br>Instructions</th>\n"
+ "<th class=\"table-sortable:numeric\" align=\"center\">Percent<br>Uncovered<br>Bytes</th>\n"
"</tr>\n"
"</thead>\n"
"<tbody>\n",
@@ -728,7 +728,7 @@ namespace Coverage {
// Range
fprintf(
report,
- "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s </br>%s</td>\n",
+ "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s <br>%s</td>\n",
rangePtr->id,
rangePtr->lowSourceLine.c_str(),
rangePtr->highSourceLine.c_str()
--
2.7.4
More information about the devel
mailing list