From 4c3ebe73d3a7cfb283aa612c8a0f35ca09a673d4 Mon Sep 17 00:00:00 2001 From: John Thacker Date: Thu, 27 Oct 2022 18:37:17 -0400 Subject: [PATCH] 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. --- epan/strutil.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/epan/strutil.c b/epan/strutil.c index 5a0d42851b..83eca5f66e 100644 --- a/epan/strutil.c +++ b/epan/strutil.c @@ -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;