Skip to content

Commit

Permalink
fix: AINSERT operand length validation (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Oct 19, 2021
1 parent 2d5ad75 commit 03d62ad
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Operands of dynamically generated statements may be incorrectly parsed
- Infinite loop during lookahead processing when model statement is located in copybook
- DOT operator in string concatenation is optional
- AINSERT operand length validation

## [0.14.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.13.0...0.14.0) (2021-08-18)

Expand Down
2 changes: 1 addition & 1 deletion cmake/external_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include(FetchContent)

FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
GIT_TAG release-1.11.0
LOG_DOWNLOAD ON
GIT_PROGRESS 1
)
Expand Down
2 changes: 1 addition & 1 deletion parser_library/src/checking/asm_instr_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ bool ainsert::check(const std::vector<const asm_operand*>& to_check,
auto second = get_simple_operand(to_check[1]);
// check first operand
if (first == nullptr || first->operand_identifier.size() < 2
|| first->operand_identifier.size() > string_max_length)
|| first->operand_identifier.size() > string_max_length + 2) // quotes
{
add_diagnostic(diagnostic_op::error_A157_AINSERT_first_op_size(to_check[0]->operand_range));
return false;
Expand Down
38 changes: 38 additions & 0 deletions parser_library/test/processing/aread_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,41 @@ A DC C
EXPECT_EQ(d.related[0].location.uri, "AINSERT:1");
EXPECT_EQ(d.related[1].location.uri, "COPYBOOK");
}

TEST(ainsert, argument_limit)
{
std::string input = R"(
MACRO
MAC
&C SETC (80)' '
AINSERT '&C',BACK
MEND
MAC
)";

analyzer a(input);

a.analyze();
a.collect_diags();

ASSERT_TRUE(a.diags().empty());
}

TEST(ainsert, argument_limit_over)
{
std::string input = R"(
MACRO
MAC
&C SETC (81)' '
AINSERT '&C',BACK
MEND
MAC
)";

analyzer a(input);

a.analyze();
a.collect_diags();

ASSERT_TRUE(matches_message_codes(a.diags(), { "A157" }));
}

0 comments on commit 03d62ad

Please sign in to comment.