Skip to content

Commit eb6c694

Browse files
committed
Buffer overrun test
1 parent ac0c309 commit eb6c694

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/generic/stage2/logger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace logger {
44
static constexpr const char * DASHES = "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
55

6-
static constexpr const bool LOG_ENABLED = false;
6+
static constexpr const bool LOG_ENABLED = true;
77
static constexpr const int LOG_EVENT_LEN = 30;
88
static constexpr const int LOG_BUFFER_LEN = 20;
99
static constexpr const int LOG_DETAIL_LEN = 50;
@@ -55,7 +55,7 @@ namespace logger {
5555
}
5656
printf("| %c ", printable_char(structurals.at_beginning() ? ' ' : structurals.current_char()));
5757
printf("| %c ", printable_char(structurals.peek_char()));
58-
printf("| %5zd ", structurals.next_structural);
58+
printf("| %5zd ", structurals.next_structural, structurals.idx);
5959
printf("| %-*s ", LOG_DETAIL_LEN, detail);
6060
printf("|\n");
6161
}

tests/basictests.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ namespace document_tests {
233233
}
234234
return true;
235235
}
236+
bool padded_with_open_bracket() {
237+
std::cout << __func__ << std::endl;
238+
simdjson::dom::parser parser;
239+
// This is a valid document ([]), but it's padded with open braces.
240+
auto error = parser.parse("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[", 2, false).error();
241+
if (error) { std::cerr << "Error: " << error << std::endl; return false; }
242+
return true;
243+
}
236244
// returns true if successful
237245
bool stable_test() {
238246
std::cout << __func__ << std::endl;
@@ -340,12 +348,15 @@ namespace document_tests {
340348
return true;
341349
}
342350
bool run() {
343-
return bad_example() &&
344-
count_array_example() &&
345-
count_object_example() &&
346-
stable_test() &&
347-
skyprophet_test() &&
348-
lots_of_brackets();
351+
return true
352+
// && bad_example()
353+
// && count_array_example()
354+
// && count_object_example()
355+
&& padded_with_open_bracket()
356+
// && stable_test()
357+
// && skyprophet_test()
358+
// && lots_of_brackets()
359+
;
349360
}
350361
}
351362

@@ -1934,13 +1945,14 @@ int main(int argc, char *argv[]) {
19341945
printf("unsupported CPU\n");
19351946
}
19361947
std::cout << "Running basic tests." << std::endl;
1937-
if (parse_api_tests::run() &&
1938-
dom_api_tests::run() &&
1939-
type_tests::run() &&
1940-
format_tests::run() &&
1941-
document_tests::run() &&
1942-
number_tests::run() &&
1943-
document_stream_tests::run()
1948+
if (true
1949+
// && parse_api_tests::run()
1950+
// && dom_api_tests::run()
1951+
// && type_tests::run()
1952+
// && format_tests::run()
1953+
&& document_tests::run()
1954+
// && number_tests::run()
1955+
// && document_stream_tests::run()
19441956
) {
19451957
std::cout << "Basic tests are ok." << std::endl;
19461958
return EXIT_SUCCESS;

0 commit comments

Comments
 (0)