]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota-fs: Make sure quota calculations don't overflow in old systems
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 9 Jun 2017 20:42:34 +0000 (23:42 +0300)
committerGitLab <gitlab@git.dovecot.net>
Sat, 10 Jun 2017 08:38:45 +0000 (11:38 +0300)
Patch by M. Balridge

src/plugins/quota/quota-fs.c

index cfabc9a3152352e8adca72ec330ba984c09de5d4..333172d84c432f3a967b95f480844824651c4604 100644 (file)
@@ -590,10 +590,10 @@ fs_quota_get_linux(struct fs_quota_root *root, bool group,
                }
 
                /* values always returned in 512 byte blocks */
-               *bytes_value_r = xdqblk.d_bcount * 512;
-               *bytes_limit_r = xdqblk.d_blk_softlimit * 512;
+               *bytes_value_r = xdqblk.d_bcount * 512ULL;
+               *bytes_limit_r = xdqblk.d_blk_softlimit * 512ULL;
                if (*bytes_limit_r == 0) {
-                       *bytes_limit_r = xdqblk.d_blk_hardlimit * 512;
+                       *bytes_limit_r = xdqblk.d_blk_hardlimit * 512ULL;
                }
                *count_value_r = xdqblk.d_icount;
                *count_limit_r = xdqblk.d_ino_softlimit;
@@ -624,13 +624,13 @@ fs_quota_get_linux(struct fs_quota_root *root, bool group,
                }
 
 #if _LINUX_QUOTA_VERSION == 1
-               *bytes_value_r = dqblk.dqb_curblocks * 1024;
+               *bytes_value_r = dqblk.dqb_curblocks * 1024ULL;
 #else
                *bytes_value_r = dqblk.dqb_curblocks;
 #endif
-               *bytes_limit_r = dqblk.dqb_bsoftlimit * 1024;
+               *bytes_limit_r = dqblk.dqb_bsoftlimit * 1024ULL;
                if (*bytes_limit_r == 0) {
-                       *bytes_limit_r = dqblk.dqb_bhardlimit * 1024;
+                       *bytes_limit_r = dqblk.dqb_bhardlimit * 1024ULL;
                }
                *count_value_r = dqblk.dqb_curinodes;
                *count_limit_r = dqblk.dqb_isoftlimit;