Skip to content

Commit

Permalink
fix potential multi-span header corruption from memcpy vs memmove (e.…
Browse files Browse the repository at this point in the history
…g. compiled w emcc) (#80)
  • Loading branch information
liquidaty authored Nov 20, 2022
1 parent 058a990 commit 1b4c4f4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/zsv_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ static int collate_header_append(struct zsv_scanner *scanner, struct collate_hea
// move prior cell value
size_t old_cell_len = ch->lengths[i-1]; // old_cell_len includes delim
if(old_cell_len) {
memcpy(new_row + new_row_end - old_cell_len,
new_row + old_row_end - old_cell_len,
old_cell_len);
// need memmove, not memcpy
memmove(new_row + new_row_end - old_cell_len,
new_row + old_row_end - old_cell_len,
old_cell_len);
old_row_end -= old_cell_len;
new_row_end -= old_cell_len;
}
Expand Down

0 comments on commit 1b4c4f4

Please sign in to comment.