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 template interpolations
|
||||||
* allow empty templates
|
* allow empty templates
|
||||||
* fix bug in serializer when the `context_stack.size()` exceeds `CHAR_MAX`
|
* 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:
|
quality:
|
||||||
* add fuzzing
|
* add fuzzing
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@@ -49,6 +51,9 @@ public:
|
|||||||
if (size + 2 + it->heredoc_identifier.size() >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
|
if (size + 2 + it->heredoc_identifier.size() >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (it->heredoc_identifier.size() > CHAR_MAX) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
buf[size++] = it->type;
|
buf[size++] = it->type;
|
||||||
buf[size++] = it->heredoc_identifier.size();
|
buf[size++] = it->heredoc_identifier.size();
|
||||||
it->heredoc_identifier.copy(&buf[size], it->heredoc_identifier.size());
|
it->heredoc_identifier.copy(&buf[size], it->heredoc_identifier.size());
|
||||||
|
|||||||
@@ -228,3 +228,23 @@ END
|
|||||||
(heredoc_identifier)
|
(heredoc_identifier)
|
||||||
(template_literal)
|
(template_literal)
|
||||||
(heredoc_identifier)))))))
|
(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