diff options
author | Philipp Middendorf <philipp.middendorf@desy.de> | 2024-04-19 14:43:29 +0200 |
---|---|---|
committer | Thomas White <thomas.white@desy.de> | 2024-04-19 16:33:00 +0200 |
commit | da37b099625c602a5612c27cb2ad16ecc992f812 (patch) | |
tree | 4401187d31e6a43e9378c619ccb849a4f6f39f40 /src/gui_index.c | |
parent | 3274d3d3152d60d7c1f425d2da649e9c2c37d99e (diff) |
GUI: Fix buffer overflow in "delete_gui_tempdir"
Diffstat (limited to 'src/gui_index.c')
-rw-r--r-- | src/gui_index.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui_index.c b/src/gui_index.c index 218331eb..19a96afa 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -540,6 +540,7 @@ static void delete_gui_tempdir(char *tmpdir) { char *path; int i; + size_t pathlen; /* List of files which it's safe to delete */ char *files[] = {"gmon.out", "mosflm.lp", "SUMMARY", "XDS.INP", @@ -552,11 +553,12 @@ static void delete_gui_tempdir(char *tmpdir) if ( tmpdir == NULL ) return; - path = calloc(strlen(tmpdir)+64, 1); + pathlen = strlen(tmpdir)+64; + path = calloc(pathlen, 1); if ( path == NULL ) return; for ( i=0; i<n_files; i++ ) { - snprintf(path, 127, "%s/%s", tmpdir, files[i]); + snprintf(path, pathlen, "%s/%s", tmpdir, files[i]); unlink(path); } |