fix bug when heredoc_identifier length exceeds CHAR_MAX
This commit is contained in:
@@ -7,6 +7,7 @@ fix:
|
||||
* allow empty template interpolations
|
||||
* allow empty templates
|
||||
* fix bug in serializer when the `context_stack.size()` exceeds `CHAR_MAX`
|
||||
* fix bug in serializer when the `heredoc_identifier.size()` exceeds `CHAR_MAX`
|
||||
|
||||
quality:
|
||||
* add fuzzing
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <wctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using std::vector;
|
||||
@@ -49,6 +51,9 @@ public:
|
||||
if (size + 2 + it->heredoc_identifier.size() >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
if (it->heredoc_identifier.size() > CHAR_MAX) {
|
||||
return 0;
|
||||
}
|
||||
buf[size++] = it->type;
|
||||
buf[size++] = it->heredoc_identifier.size();
|
||||
it->heredoc_identifier.copy(&buf[size], it->heredoc_identifier.size());
|
||||
|
||||
@@ -228,3 +228,23 @@ END
|
||||
(heredoc_identifier)
|
||||
(template_literal)
|
||||
(heredoc_identifier)))))))
|
||||
|
||||
================================================================================
|
||||
heredoc with identifier that does not fit into the serialization buffer (should not crash)
|
||||
================================================================================
|
||||
|
||||
foo = <<XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(config_file
|
||||
(body
|
||||
(attribute
|
||||
(identifier)
|
||||
(expression
|
||||
(template_expr
|
||||
(heredoc_template
|
||||
(heredoc_start)
|
||||
(heredoc_identifier)
|
||||
(heredoc_identifier)))))))
|
||||
|
||||
Reference in New Issue
Block a user