Skip to content

Commit

Permalink
Fix an additional fuzzing issue (LLNL#240)
Browse files Browse the repository at this point in the history
* Fix an additional fuzzing issue and try to resolve the gcc 4.8 container issue

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update suppressions file for cppcheck

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
phlptp and pre-commit-ci[bot] authored Aug 23, 2022
1 parent 9415d2e commit c9cc61b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ jobs:
gcc8:
containerImage: gcc:8
units.std: 17
gcc4.8:
containerImage: gcc:4.8
units.std: 11
units.options:
clang3.4:
containerImage: silkeh/clang:3.4
units.std: 11
Expand Down Expand Up @@ -117,6 +113,10 @@ jobs:
vmImage: 'ubuntu-latest'
strategy:
matrix:
gcc4.8:
containerImage: helics/buildenv:gcc4-8-builder
units.std: 11
units.options:
clang8:
containerImage: helics/buildenv:clang8-builder
units.std: 14
Expand Down
4 changes: 2 additions & 2 deletions config/cppcheck_suppressions.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
unusedFunction:units/x12_conv.cpp:1024
unusedFunction:units/r20_conv.cpp:2738
unusedFunction:units/x12_conv.cpp:1009
passedByValue:units/units.cpp:1068
passedByValue:units/units.cpp:1085
passedByValue:units/units.cpp:1074
passedByValue:units/units.cpp:1091
1 change: 1 addition & 0 deletions test/files/fuzz_issues/meas_fail31
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e-1*c�
2 changes: 1 addition & 1 deletion test/fuzz_issue_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ TEST_P(measProblems, measFiles)
}
}

INSTANTIATE_TEST_SUITE_P(measFiles, measProblems, ::testing::Range(0, 31));
INSTANTIATE_TEST_SUITE_P(measFiles, measProblems, ::testing::Range(0, 32));

class meas64Problems : public ::testing::TestWithParam<int> {};

Expand Down
6 changes: 6 additions & 0 deletions units/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,12 @@ static std::string
}

if (!propUnitString.empty()) {
if (propUnitString.front() == '(' && propUnitString.back() == ')') {
if (propUnitString.find_first_of('(', 1) == std::string::npos) {
propUnitString.pop_back();
propUnitString.erase(propUnitString.begin());
}
}
if (propUnitString.find("00000") != std::string::npos) {
reduce_number_length(propUnitString, '0');
}
Expand Down
2 changes: 1 addition & 1 deletion units/units_conversion_maps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ UNITS_CPP14_CONSTEXPR_OBJECT std::array<std::pair<unit, const char*>, 180>
{unit_cast(precise::us::tbsp), "tbsp"},
{unit_cast(precise::us::quart), "qt"},
{unit_cast(precise::energy::eV / (constants::c.as_unit().pow(2))),
"eV*[c]^-2"},
"(eV*[c]^-2)"},
{unit_cast(precise::data::GiB), "GiB"},
{unit_cast(precise::other::ppm), "ppm"},
{unit_cast(precise::other::ppb), "ppb"}}};
Expand Down

0 comments on commit c9cc61b

Please sign in to comment.