From fd0391c3d7796bf37856c2a988e0b5478f85f250 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Thu, 13 Jun 2024 17:53:32 +0200 Subject: [PATCH 1/2] fix leak in compress.mod --- src/mod/compress.mod/compress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mod/compress.mod/compress.c b/src/mod/compress.mod/compress.c index c4a86fb76..f41617c62 100644 --- a/src/mod/compress.mod/compress.c +++ b/src/mod/compress.mod/compress.c @@ -88,8 +88,10 @@ static int is_compressedfile(char *filename) if (!zin) return COMPF_FAILED; len1 = gzread(zin, buf1, sizeof(buf1)); - if (len1 < 0) + if (len1 < 0) { + gzclose(zin); return COMPF_FAILED; + } if (gzclose(zin) != Z_OK) return COMPF_FAILED; From b9a825808938da87c6390593affb1c3996259417 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:27:49 +0200 Subject: [PATCH 2/2] More --- src/mod/compress.mod/compress.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mod/compress.mod/compress.c b/src/mod/compress.mod/compress.c index f41617c62..34de2ccfc 100644 --- a/src/mod/compress.mod/compress.c +++ b/src/mod/compress.mod/compress.c @@ -144,6 +144,7 @@ static int uncompress_to_file(char *f_src, char *f_target) fout = fopen(f_target, "wb"); if (!fout) { + gzclose(fin); putlog(LOG_MISC, "*", "Failed to uncompress file `%s': open failed: %s.", f_src, strerror(errno)); return COMPF_ERROR; @@ -154,6 +155,7 @@ static int uncompress_to_file(char *f_src, char *f_target) if (len < 0) { putlog(LOG_MISC, "*", "Failed to uncompress file `%s': gzread failed.", f_src); + gzclose(fin); fclose(fout); return COMPF_ERROR; } @@ -162,6 +164,7 @@ static int uncompress_to_file(char *f_src, char *f_target) if ((int) fwrite(buf, 1, (unsigned int) len, fout) != len) { putlog(LOG_MISC, "*", "Failed to uncompress file `%s': fwrite " "failed: %s.", f_src, strerror(errno)); + gzclose(fin); fclose(fout); return COMPF_ERROR; } @@ -169,6 +172,7 @@ static int uncompress_to_file(char *f_src, char *f_target) if (fclose(fout)) { putlog(LOG_MISC, "*", "Failed to uncompress file `%s': fclose failed: %s.", f_src, strerror(errno)); + gzclose(fin); return COMPF_ERROR; } if (gzclose(fin) != Z_OK) {