Check element size when parsing tokens.

This commit is contained in:
Nicolas Tsiftes 2018-08-20 14:07:14 +02:00
parent 21042ae748
commit a73822176a

View File

@ -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';