Check element size when parsing tokens.
@@ -207,6 +207,10 @@ next_string(lexer_t *lexer, const char *s)
*lexer->token = STRING_VALUE;
lexer->input = end + 1; /* Skip the closing delimiter. */
+ if(length > DB_MAX_ELEMENT_SIZE - 1) {
+ length = DB_MAX_ELEMENT_SIZE - 1;
+ }
+
memcpy(lexer->value, s, length);
(*lexer->value)[length] = '\0';
@@ -236,6 +240,10 @@ next_token(lexer_t *lexer, const char *s)
*lexer->token = IDENTIFIER;
+ if(length > DB_MAX_ELEMENT_SIZE - 1) {
+ length = DB_MAX_ELEMENT_SIZE - 1;
+ }
+
memcpy(lexer->value, s, length);
(*lexer->value)[length] = '\0';
