summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-05-28 15:37:59 -0300
committerVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-05-28 15:43:16 -0300
commit7cf9dbd3b573000c959ea958461328507a26af0d (patch)
tree947c781ac0c0413dd7349c8be045c2c4c6825f2e
parent3118804df6e938cd197bac5294a8da022163dcc4 (diff)
downloadobexd-7cf9dbd3b573000c959ea958461328507a26af0d.tar.gz
Fix dealing with large files
In C, the result of an operation has always the size of the largest operand, in this case both operands are unsigned longs, which was causing the operation to overflow on 32bit machines. The solution is to force an operand to be of a size that would not overflow and to store the result somewhere with a safe size.
-rw-r--r--plugins/filesystem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/plugins/filesystem.c b/plugins/filesystem.c
index 633036b..2844329 100644
--- a/plugins/filesystem.c
+++ b/plugins/filesystem.c
@@ -138,6 +138,7 @@ static void *filesystem_open(const char *name, int oflag, mode_t mode,
char *folder;
gboolean root;
int fd = open(name, oflag, mode);
+ uint64_t avail;
if (fd < 0) {
if (err)
@@ -181,7 +182,8 @@ static void *filesystem_open(const char *name, int oflag, mode_t mode,
if (size == NULL)
goto done;
- if (buf.f_bsize * buf.f_bavail < *size) {
+ avail = (uint64_t) buf.f_bsize * buf.f_bavail;
+ if (avail < *size) {
if (err)
*err = -ENOSPC;
goto failed;