print.c: add length check to loop

Note that it was impossible to actually overflow
the buffer, and there is a check to flush and restart
if it gets to within a few bytes of the end, but static
analyzers (CID: 1477927) are unlikely to be able to work
this out.
This commit is contained in:
Martin Mathieson 2021-06-13 22:09:05 +01:00 committed by Wireshark GitLab Utility
parent 30f3d72061
commit 8e099bb0c7
1 changed files with 1 additions and 1 deletions

View File

@ -1812,7 +1812,7 @@ print_escaped_xml(FILE *fh, const char *unescaped_string)
return;
}
for (p = unescaped_string; *p != '\0'; p++) {
for (p = unescaped_string; *p != '\0' && (offset<(ESCAPED_BUFFER_MAX-1)); p++) {
switch (*p) {
case '&':
(void) g_strlcpy(&temp_buffer[offset], "&amp;", ESCAPED_BUFFER_MAX-offset);