diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9189aecece5345a60ec850332af0fca826e14603..45ebdf60c4dcd6fdac658c24ad70a10190623430 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,13 @@ +Changes in Release 1.7.1 +-------------------------------------------------------------------------------- + + * Fixed an issue that could cause the star format parser (mmCIF, chemical + components dictionary) to enter an infinite loop + * Chemical components dictionary was extended by new chemical classes + introduced by PDB + * Fixed unit tests + * Improved documentation + Changes in Release 1.7 -------------------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f582069ba52a1b79e281c8866d6f591c5f1942e..2cf4c283a4cbfd59833a4d76837da48948dbe9f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(OpenStructure CXX C) set (CMAKE_EXPORT_COMPILE_COMMANDS 1) set (OST_VERSION_MAJOR 1) set (OST_VERSION_MINOR 7) -set (OST_VERSION_PATCH 0) +set (OST_VERSION_PATCH 1) set (OST_VERSION_STRING ${OST_VERSION_MAJOR}.${OST_VERSION_MINOR}.${OST_VERSION_PATCH} ) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_support) include(OST) diff --git a/modules/io/src/mol/star_parser.cc b/modules/io/src/mol/star_parser.cc index 80043259b4df5fdf34ee81de6bf471696d03bc5a..214eb626c9f743a1cbbb218bede0ad7f795b2f73 100644 --- a/modules/io/src/mol/star_parser.cc +++ b/modules/io/src/mol/star_parser.cc @@ -550,11 +550,15 @@ void StarParser::Parse() case 'd': if (tline.length()>=5 && StringRef("data_", 5)==tline.substr(0, 5)) { this->ParseData(); + } else { + throw IOException("Missing 'data_' control structure"); } break; case 'g': if (tline.length()>=7 && StringRef("global_", 7)==tline.substr(0, 7)) { this->ParseGlobal(); + } else { + throw IOException("Missing 'global_' control structure"); } break; case '#': diff --git a/modules/io/tests/test_star_parser.cc b/modules/io/tests/test_star_parser.cc index 6ff217b748c123770f789a2168d540be3f1ef94d..c4e40fdbda137d74293282a592884fb5aa7e8305 100644 --- a/modules/io/tests/test_star_parser.cc +++ b/modules/io/tests/test_star_parser.cc @@ -389,6 +389,20 @@ BOOST_AUTO_TEST_CASE(star_items_as_row) BOOST_TEST_MESSAGE(" done."); } +BOOST_AUTO_TEST_CASE(star_broken_data) +{ + std::ifstream s("testfiles/broken_data.cif"); + LoopTestParser star_p(s); + BOOST_CHECK_THROW(star_p.Parse(), IOException); +} + +BOOST_AUTO_TEST_CASE(star_broken_global) +{ + std::ifstream s("testfiles/broken_global.cif"); + LoopTestParser star_p(s); + BOOST_CHECK_THROW(star_p.Parse(), IOException); +} + BOOST_AUTO_TEST_CASE(star_missing_data) { std::ifstream s("testfiles/missing_data.cif"); diff --git a/modules/io/tests/testfiles/broken_data.cif b/modules/io/tests/testfiles/broken_data.cif new file mode 100644 index 0000000000000000000000000000000000000000..2ae242255c2bd8c6e952ffee6d1815ee01f6335a --- /dev/null +++ b/modules/io/tests/testfiles/broken_data.cif @@ -0,0 +1 @@ +d lines starting with a 'd' kicked the parser into an infinite loop. diff --git a/modules/io/tests/testfiles/broken_global.cif b/modules/io/tests/testfiles/broken_global.cif new file mode 100644 index 0000000000000000000000000000000000000000..0f340e0befe0077229b53b121979181ec3c890fc --- /dev/null +++ b/modules/io/tests/testfiles/broken_global.cif @@ -0,0 +1 @@ +g lines starting with a 'g' kicked the parser into an infinite loop.