Skip to content

Commit

Permalink
fix: replace strcpy with safer memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-Q committed Apr 20, 2024
1 parent 14159c8 commit 1634520
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ unsigned tree_sitter_sql_external_scanner_serialize(void *payload, char *buffer)
if (tag_length >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
return 0;
}
strcpy(buffer, state->start_tag);
memcpy(buffer, state->start_tag, strlen(state->start_tag) + 1);
if (state->start_tag != NULL) {
free(state->start_tag);
state->start_tag = NULL;
Expand All @@ -183,6 +183,6 @@ void tree_sitter_sql_external_scanner_deserialize(void *payload, const char *buf
// A length of 1 can't exists.
if (length > 1) {
state->start_tag = malloc(length);
strcpy(state->start_tag, buffer);
memcpy(state->start_tag, buffer, length);
}
}

0 comments on commit 1634520

Please sign in to comment.