1From 37ad222868e52271905b94afea4fc780d83294b4 Mon Sep 17 00:00:00 2001
2From: Frank Denis <github@pureftpd.org>
3Date: Tue, 23 Nov 2021 18:53:34 +0100
4Subject: [PATCH] Initialize the max upload file size when quotas are enabled
5
6Due to an unwanted check, files causing the quota to be exceeded
7were deleted after the upload, but not during the upload.
8
9The bug was introduced in 2009 in version 1.0.23
10
11Spotted by @DroidTest, thanks!
12
13[Retrieved from:
14https://github.com/jedisct1/pure-ftpd/commit/37ad222868e52271905b94afea4fc780d83294b4]
15Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
16---
17 src/ftpd.c | 3 +--
18 1 file changed, 1 insertion(+), 2 deletions(-)
19
20diff --git a/src/ftpd.c b/src/ftpd.c
21index d856839..be2fd78 100644
22--- a/src/ftpd.c
23+++ b/src/ftpd.c
24@@ -4247,8 +4247,7 @@ void dostor(char *name, const int append, const int autorename)
25     if (quota_update(&quota, 0LL, 0LL, &overflow) == 0 &&
26         (overflow > 0 || quota.files >= user_quota_files ||
27          quota.size > user_quota_size ||
28-         (max_filesize >= (off_t) 0 &&
29-          (max_filesize = user_quota_size - quota.size) < (off_t) 0))) {
30+         (max_filesize = user_quota_size - quota.size) < (off_t) 0)) {
31         overflow = 1;
32         (void) close(f);
33         goto afterquota;
34