diff options
author | Jeremy Allison <jra@samba.org> | 2004-07-30 00:19:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:16 -0500 |
commit | 1fed92da2f5255cd8d07ccdf528c98eb0daa087c (patch) | |
tree | 157e0a1901c2b5378c4f87d2f372b1b1a32ba8c9 /source3/lib | |
parent | 6179279472ae94f429c06ed86f3d54302e1ec92c (diff) | |
download | samba-1fed92da2f5255cd8d07ccdf528c98eb0daa087c.tar.gz samba-1fed92da2f5255cd8d07ccdf528c98eb0daa087c.tar.bz2 samba-1fed92da2f5255cd8d07ccdf528c98eb0daa087c.zip |
r1608: Fix from Nick THOMPSON <nickthompson@agere.com> to protect smbd
against broken filesystems which return zero blocksize.
Jeremy.
(This used to be commit 23d157a0bea16366f0361ab68193b479ed844291)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/fsusage.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source3/lib/fsusage.c b/source3/lib/fsusage.c index bb7cff0645..036f276319 100644 --- a/source3/lib/fsusage.c +++ b/source3/lib/fsusage.c @@ -26,12 +26,17 @@ */ static SMB_BIG_UINT adjust_blocks(SMB_BIG_UINT blocks, SMB_BIG_UINT fromsize, SMB_BIG_UINT tosize) { - if (fromsize == tosize) /* e.g., from 512 to 512 */ + if (fromsize == tosize) { /* e.g., from 512 to 512 */ return blocks; - else if (fromsize > tosize) /* e.g., from 2048 to 512 */ + } else if (fromsize > tosize) { /* e.g., from 2048 to 512 */ return blocks * (fromsize / tosize); - else /* e.g., from 256 to 512 */ + } else { /* e.g., from 256 to 512 */ + /* Protect against broken filesystems... */ + if (fromsize == 0) { + fromsize = tosize; + } return (blocks + 1) / (tosize / fromsize); + } } /* this does all of the system specific guff to get the free disk space. |