epan: ensure that the result of ws_label_strcpy is terminated

Unless there is no available space, ensure that the label_str
passed into ws_label_strcpy is null terminated, in the cases
where the string to copy is the empty string, or begins with
invalid UTF-8.

Fix #18560. Fix #18551.
This commit is contained in:
John Thacker 2022-10-27 18:37:17 -04:00
parent d46e7f90f2
commit 4c3ebe73d3
1 changed files with 2 additions and 0 deletions

View File

@ -815,6 +815,8 @@ ws_label_strcpy(char *label_str, size_t buf_size, size_t pos,
ssize_t idx, src_len;
ssize_t free_len;
label_str[pos] = '\0';
idx = 0;
src_len = strlen(str);
free_len = buf_size - pos - 1;