diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c
index 6660b58..ae7ceea 100644
--- a/obexd/plugins/filesystem.c
+++ b/obexd/plugins/filesystem.c
}
if (oflag == O_RDONLY) {
- *size = stats.st_size;
+ if (size)
+ *size = stats.st_size;
return GINT_TO_POINTER(fd);
}
if (fstatvfs(fd, &buf) < 0)
goto failed;
- if (buf.f_bsize * buf.f_bavail < *size) {
+ if (size == NULL)
+ return GINT_TO_POINTER(fd);
+
+ if (buf.f_bsize * buf.f_bavail < (size_t) *size) {
errno = ENOSPC;
goto failed;
}
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index 192b3dd..d0afc18 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
gint len;
path = g_build_filename(os->current_folder, os->name, NULL);
-
os->object = os->driver->open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600,
- (size_t *) &os->size);
+ os->size != OBJECT_SIZE_UNKNOWN ?
+ (size_t *) &os->size : NULL);
if (os->object == NULL) {
error("open(%s): %s (%d)", path, strerror(errno), errno);
g_free(path);