From 595d3e0cf3334dc9967d971cd17bfdfdb99f8ba7 Mon Sep 17 00:00:00 2001 From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk> Date: Tue, 13 Oct 2015 11:58:05 +0100 Subject: [PATCH] fix unchecked copy into fixed size buffer strncpy/strncat, re #13951 --- MantidPlot/src/zlib123/minigzip.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MantidPlot/src/zlib123/minigzip.c b/MantidPlot/src/zlib123/minigzip.c index 6f12762c8ec..5263508908d 100644 --- a/MantidPlot/src/zlib123/minigzip.c +++ b/MantidPlot/src/zlib123/minigzip.c @@ -209,8 +209,9 @@ void file_compress(file, mode) FILE *in; gzFile out; - strcpy(outfile, file); - strcat(outfile, GZ_SUFFIX); + strncpy(outfile, file, MAX_NAME_LEN-1); + outfile[MAX_NAME_LEN-1] = '\0'; + strncat(outfile, GZ_SUFFIX, MAX_NAME_LEN - strlen(outfile) - 1); in = fopen(file, "rb"); if (in == NULL) { -- GitLab