Check element size when parsing tokens.
This commit is contained in:
parent
21042ae748
commit
a73822176a
@ -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';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user