From 50dc7e62e982b5c3cecf47d1c73dd8ecaa55eea6 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Mon, 4 Aug 2014 14:38:11 -0400 Subject: [PATCH] Plug a memory and fd leak if keeptemps is enabled --- libclamav/xdp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libclamav/xdp.c b/libclamav/xdp.c index b07519e6d..566f7e1b1 100644 --- a/libclamav/xdp.c +++ b/libclamav/xdp.c @@ -85,6 +85,8 @@ char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz) cli_dbgmsg("dump_xdp: Dumped payload to %s\n", filename); + close(fd); + return filename; } @@ -105,8 +107,11 @@ int cli_scanxdp(cli_ctx *ctx) if (!(buf)) return CL_EREAD; - if (ctx->engine->keeptmp) - dump_xdp(ctx, buf, map->len); + if (ctx->engine->keeptmp) { + dumpname = dump_xdp(ctx, buf, map->len); + if (dumpname) + free(dumpname); + } /* * Since a PDF file can contain embedded XDP documents,