Added a nesting limit to the parser to prevent stack overflow that could be a security issue

This commit is contained in:
Benoit Blanchon
2014-11-06 10:24:37 +01:00
parent 2e4dd2d591
commit a3425a6306
5 changed files with 104 additions and 7 deletions

View File

@@ -13,7 +13,8 @@ namespace Internals {
class JsonParser {
public:
JsonParser(JsonBuffer *buffer, char *json) : _buffer(buffer), _ptr(json) {}
JsonParser(JsonBuffer *buffer, char *json, uint8_t nestingLimit)
: _buffer(buffer), _ptr(json), _nestingLimit(nestingLimit) {}
JsonArray &parseArray();
JsonObject &parseObject();
@@ -33,6 +34,7 @@ class JsonParser {
JsonBuffer *_buffer;
char *_ptr;
uint8_t _nestingLimit;
};
}
}