From ba6bb9bfd84ba7b4ae6ab842b167d569b1625d36 Mon Sep 17 00:00:00 2001 From: offsides <josh@honorablemenschen.com> Date: Thu, 28 Mar 2024 15:28:08 -0400 Subject: [PATCH] Fix clam scanning path issues when using mod_vroot When using mod_vroot, the chroot path gets prepended to the scan path when it isn't needed. This fixes that problem. --- mod_clamav.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mod_clamav.c b/mod_clamav.c index 798065b..8b112d1 100644 --- a/mod_clamav.c +++ b/mod_clamav.c @@ -516,11 +516,13 @@ static int clamav_fsio_close(pr_fh_t *fh, int fd) { (void) pr_trace_msg("clamav", 8, "vwd=%s fh_path=%s chroot=%s cwd=%s buf=%s", pr_fs_getvwd(), abs_path, session.chroot_path, pr_fs_getcwd(), buf); - if (strcmp(buf, pr_fs_getcwd()) != 0) { - if (strcmp(pr_fs_getcwd(), "/") != 0) { - char *pos = strstr(buf, pr_fs_getcwd()); - if (pos) { - *pos = 0; + if (session.chroot_path && strcmp(session.chroot_path, "/") != 0) { + if (strcmp(buf, pr_fs_getcwd()) != 0) { + if (strcmp(pr_fs_getcwd(), "/") != 0) { + char *pos = strstr(buf, pr_fs_getcwd()); + if (pos) { + *pos = 0; + } } }