Package: fusedav
Version: 0.2-3
Severity: important
Tags: upstream patch

listxattr_iterator():

* out-of-space calculation should use "n" to determine the bump
  in l->size for reporting future space usage.

dav_listxattr():

* there is no need to subtract one byte from size when setting
  l.space, snprintf() already accounts for the terminating
  null-byte in its buffer and size arguments.

* snprintf() will already null-terminate as will
  "memcpy(l.list, MIME_XATTR, sizeof(MIME_XATTR))",
  so there is no need to explicitly terminate l.list.

* There is no need to add one byte to l.size in the return
  value, all of the previous space/buffer calculations account
  for the trailing null byte.

This is a possible fix for http://bugs.debian.org/514330
(fusedav: Fails to copy remote).  However, I needed "cp -a"
instead of plain "cp" to replicate the issue.

-- System Information:
Debian Release: 6.0.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages fusedav depends on:
ii  fuse-utils                    2.8.4-1.1  Filesystem in USErspace (utilities
ii  libc6                         2.11.3-4   Embedded GNU C Library: Shared lib
ii  libfuse2                      2.8.4-1.1  Filesystem in USErspace library
ii  libneon27-gnutls              0.29.3-3   An HTTP and WebDAV client library 

fusedav recommends no packages.

fusedav suggests no packages.

-- no debconf information
>From e38a671e7347d5ef10965bd12720b40a1e94ab98 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalper...@yhbt.net>
Date: Wed, 24 Oct 2012 20:11:43 +0000
Subject: [PATCH] listxattr: fix space calculation leading to assertion
 failure

listxattr_iterator():

* out-of-space calculation should use "n" to determine the bump
  in l->size for reporting future space usage.

dav_listxattr():

* there is no need to subtract one byte from size when setting
  l.space, snprintf() already accounts for the terminating
  null-byte in its buffer and size arguments.

* snprintf() will already null-terminate as will
  "memcpy(l.list, MIME_XATTR, sizeof(MIME_XATTR))",
  so there is no need to explicitly terminate l.list.

* There is no need to add one byte to l.size in the return
  value, all of the previous space/buffer calculations account
  for the trailing null byte.

This is a possible fix for http://bugs.debian.org/514330
(fusedav: Fails to copy remote).  However, I needed "cp -a"
instead of plain "cp" to replicate the issue.
---
 src/fusedav.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/fusedav.c b/src/fusedav.c
index 944a929..0d8e018 100644
--- a/src/fusedav.c
+++ b/src/fusedav.c
@@ -794,8 +794,8 @@ static int listxattr_iterator(
     if (l->list) {
         n = snprintf(l->list, l->space, "user.webdav(%s;%s)", pname->nspace, 
pname->name) + 1;
         
-        if (n >= (int) l->space) {
-            l->size += l->space;
+        if (n > (int) l->space) {
+            l->size += n;
             l->space = 0;
             return 1;
             
@@ -839,7 +839,7 @@ static int dav_listxattr(
 
     if (list) {
         l.list = list;
-        l.space = size-1;
+        l.space = size;
         l.size = 0;
 
         if (l.space >= sizeof(MIME_XATTR)) {
@@ -863,12 +863,7 @@ static int dav_listxattr(
         return -EIO;
     }
 
-    if (l.list) {
-        assert(l.space > 0);
-        *l.list = 0;
-    }
-
-    return l.size+1;
+    return l.size;
 }
 
 struct getxattr_info {
-- 
1.8.0.rc0.42.gb8c78e2

Reply via email to