From 2442de3389b8a7892eb05ea0c30e7a91f58a7f38 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Mon, 27 Apr 2020 18:57:36 -0500 Subject: Fix memory error in h5dump xml 'escape the string' routine --- tools/src/h5dump/h5dump_xml.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 07cff6a..95aff48 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -783,32 +783,30 @@ xml_escape_the_string(const char *str, int slen) if (*cp == '\\') { *ncp++ = '\\'; + ncp_len--; *ncp = *cp; esc_len = 1; } else if (*cp == '\"') { *ncp++ = '\\'; + ncp_len--; *ncp = *cp; esc_len = 1; } else if (*cp == '\'') { HDstrncpy(ncp, apos, ncp_len); - ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(apos); } else if (*cp == '<') { HDstrncpy(ncp, lt, ncp_len); - ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(lt); } else if (*cp == '>') { HDstrncpy(ncp, gt, ncp_len); - ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(gt); } else if (*cp == '&') { HDstrncpy(ncp, amp, ncp_len); - ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(amp); } else { -- cgit v0.12