diff options
-rw-r--r-- | test/attr.test | 26 | ||||
-rw-r--r-- | tools/getfattr.c | 2 | ||||
-rw-r--r-- | tools/setfattr.c | 2 |
3 files changed, 21 insertions, 9 deletions
diff --git a/test/attr.test b/test/attr.test index 5cb810e..1f755ae 100644 --- a/test/attr.test +++ b/test/attr.test @@ -19,7 +19,7 @@ Try various valid and invalid names $ setfattr -n user.name f $ getfattr -d f > # file: f - > user.name + > user.name="" > $ setfattr -x user.name f @@ -98,8 +98,8 @@ Everything with one file $ getfattr -d f > # file: f > user.longername="longervalue" - > user.novalue - > user.novalue-yet + > user.novalue="" + > user.novalue-yet="" > user.short="value" > user.somename="somevalue" > @@ -108,7 +108,7 @@ Everything with one file $ getfattr -d f > # file: f > user.longername="longervalue" - > user.novalue + > user.novalue="" > user.novalue-yet="avalue-now" > user.short="value" > user.somename="somevalue" @@ -122,7 +122,7 @@ Everything with one file $ getfattr -d f > # file: f > user.longername="longervalue" - > user.novalue + > user.novalue="" > user.novalue-yet="avalue-now" > @@ -166,13 +166,13 @@ Test extended attribute block sharing $ getfattr -d f g h | sort-getfattr-output > # file: f > user.name="value" - > user.novalue + > user.novalue="" > > # file: g - > user.novalue + > user.novalue="" > > # file: h - > user.novalue + > user.novalue="" > $ setfattr -n user.name -v value g @@ -240,6 +240,16 @@ Tests for file name that contain special characters $ rm "f " +Tests for empty attribute values + + $ touch f + $ setfattr -n user.name -v '' f + $ getfattr -d f + > # file: f + > user.name="" + > + $ rm f + Tests for attribute names that contains special characters $ touch f diff --git a/tools/getfattr.c b/tools/getfattr.c index 692d2d8..9ea44d5 100644 --- a/tools/getfattr.c +++ b/tools/getfattr.c @@ -277,7 +277,7 @@ int print_attribute(const char *path, const char *name, int *header_printed) if (opt_value_only) fwrite(value, length, 1, stdout); - else if (length) { + else if (opt_dump) { const char *enc = encode(value, &length); if (enc) diff --git a/tools/setfattr.c b/tools/setfattr.c index 4f5daa9..33a4282 100644 --- a/tools/setfattr.c +++ b/tools/setfattr.c @@ -289,6 +289,8 @@ const char *decode(const char *value, size_t *size) static char *decoded; static size_t decoded_size; + if (*size == 0) + return ""; if (value[0] == '0' && (value[1] == 'x' || value[1] == 'X')) { const char *v = value+2, *end = value + *size; char *d; |