| namespace { | |
| void timeoutHandler(int) { | |
| static constexpr char message[] = | |
| "TIMEOUT: legacy Reader did not return after input EOF\n"; | |
| (void)::write(STDOUT_FILENO, message, sizeof(message) - 1); | |
| _exit(124); | |
| } | |
| } // namespace | |
| int main() { | |
| // All bytes keep the continuation bit set. BufferReader::read() returns | |
| // false at EOF, but Reader::readVarInt() ignores the result and keeps the | |
| // previous 0x81 byte in `val`, making its do/while loop non-terminating. | |
| const std::vector<uint8_t> trigger(10, 0x81); | |
| avro::OutputBuffer output; | |
| output.writeTo(reinterpret_cast<const char *>(trigger.data()), | |
| trigger.size()); | |
| avro::Reader reader(output.extractData()); | |
| std::signal(SIGALRM, timeoutHandler); | |
| alarm(2); | |
| int64_t value = 0; | |
| reader.readValue(value); | |
| alarm(0); | |
| std::cout << "UNEXPECTED: legacy Reader returned " << value << '\n'; | |
| return 1; | |
| } | |