A single log entry larger than any stack buffer must not crash us. log_to_files() used to size its buffer with a variable-length array derived from the entry length, so a caller which could influence that length could run the stack out. Nothing bounds an entry: a plugin can hand us
(node_factory)
| 5999 | |
| 6000 | |
| 6001 | def test_huge_log_entry(node_factory): |
| 6002 | """A single log entry larger than any stack buffer must not crash us. |
| 6003 | |
| 6004 | log_to_files() used to size its buffer with a variable-length array |
| 6005 | derived from the entry length, so a caller which could influence that |
| 6006 | length could run the stack out. Nothing bounds an entry: a plugin can |
| 6007 | hand us one of any size, which is what this drives. |
| 6008 | """ |
| 6009 | plugin_path = os.path.join(os.getcwd(), 'tests/plugins/hugelog.py') |
| 6010 | l1 = node_factory.get_node(options={'plugin': plugin_path}) |
| 6011 | |
| 6012 | assert l1.rpc.call('hugelog', {'bytelen': 8 * 1024 * 1024})['logged'] == 8 * 1024 * 1024 |
| 6013 | |
| 6014 | # Still alive, and still answering. |
| 6015 | assert l1.rpc.getinfo()['id'] == l1.info['id'] |
| 6016 | |
| 6017 | |
| 6018 | def test_command_collision(node_factory): |