summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-10-21 19:27:29 +0100
committerLars Wirzenius <liw@liw.fi>2012-10-21 19:27:29 +0100
commitf047077aa2015b6b7cf2fe9dc0508029588fd741 (patch)
tree2beb5a1623178a6c7a0a361f887343b8e82fba66
parentb20d48b7c1cab77d0ba7950cab4cb0163d99b396 (diff)
downloadsummain-f047077aa2015b6b7cf2fe9dc0508029588fd741.tar.gz
Handle empty extended attribute values
-rw-r--r--NEWS2
-rw-r--r--_summainmodule.c2
-rwxr-xr-xtests/xattrs.script3
3 files changed, 5 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 42f1a0d..6955899 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Version X.Y, released UNRELEASED
* Changed to use the libc-provided xattr library, instead of the external
one. Thanks, Игорь Пашев for pointing this out.
+* Fixed bug: Summain can now handle extended attributes with an empty
+ value.
Version 0.16, released 2012-09-29
---------------------------------
diff --git a/_summainmodule.c b/_summainmodule.c
index 069dafe..998469a 100644
--- a/_summainmodule.c
+++ b/_summainmodule.c
@@ -116,7 +116,7 @@ lgetxattr_wrapper(PyObject *self, PyObject *args)
char *buf = malloc(bufsize);
ssize_t n = lgetxattr(filename, attrname, buf, bufsize);
- if (n > 0)
+ if (n >= 0)
o = Py_BuildValue("s#", buf, (int) n);
else if (n == -1 && errno != ERANGE)
o = Py_BuildValue("i", errno);
diff --git a/tests/xattrs.script b/tests/xattrs.script
index 3f66b00..1d64954 100755
--- a/tests/xattrs.script
+++ b/tests/xattrs.script
@@ -5,7 +5,8 @@ set -e
umask 0002
mkdir -m 0775 "$DATADIR/xattrs"
touch "$DATADIR/xattrs/file"
-if setfattr -n user.foo -v bar "$DATADIR/xattrs/file" 2> /dev/null
+if setfattr -n user.foo -v bar "$DATADIR/xattrs/file" 2> /dev/null &&
+ setfattr -n user.empty -v '""' "$DATADIR/xattrs/file" 2> /dev/null
then
./summain --exclude=mtime --exclude=uid --exclude=username \
--exclude=gid --exclude=group --exclude=ino --exclude=dev \