summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/backupclient/BackupClientFileAttributes.cpp5
-rw-r--r--test/bbackupd/testbbackupd.cpp17
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp
index 70c0d09d..a31cd7b4 100644
--- a/lib/backupclient/BackupClientFileAttributes.cpp
+++ b/lib/backupclient/BackupClientFileAttributes.cpp
@@ -511,6 +511,10 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
// Find size of attribute (must call with buffer and length 0 on some platforms,
// as -1 is returned if the data doesn't fit.)
int valueSize = ::lgetxattr(Filename, attrKey.c_str(), 0, 0);
+ if(valueSize<0)
+ {
+ THROW_EXCEPTION(CommonException, OSFileError);
+ }
// Resize block, if needed
if(xattrSize+valueSize>xattrBufferSize)
@@ -522,7 +526,6 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
// This gets the attribute value (may be text or binary), no termination
valueSize = ::lgetxattr(Filename, attrKey.c_str(), buffer+xattrSize, xattrBufferSize-xattrSize);
-
if(valueSize<0)
{
THROW_EXCEPTION(CommonException, OSFileError);
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index 72917978..0e01619a 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -44,6 +44,11 @@
#include "MemLeakFindOn.h"
+// ENOATTR may be defined in a separate header file which we may not have
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
// two cycles and a bit
#define TIME_TO_WAIT_FOR_BACKUP_OPERATION 12
@@ -194,7 +199,7 @@ bool write_xattr_test(const char *filename, const char *attrName, unsigned int l
}
else
{
- char data[4096];
+ char data[1024];
if(length > sizeof(data)) length = sizeof(data);
if(::fread(data, length, 1, xattrTestDataHandle) != 1)
@@ -327,7 +332,7 @@ int test_basics()
#ifdef HAVE_SYS_XATTR_H
// Write some attributes to the file, checking for ENOTSUP
bool xattrNotSupported = false;
- if(!write_xattr_test("testfiles/test1", "attr_1", 1276, &xattrNotSupported) && xattrNotSupported)
+ if(!write_xattr_test("testfiles/test1", "user.attr_1", 1000, &xattrNotSupported) && xattrNotSupported)
{
::printf("***********\nYour platform supports xattr, but your filesystem does not.\nSkipping tests.\n***********\n");
}
@@ -336,8 +341,8 @@ int test_basics()
BackupClientFileAttributes x1, x2, x3, x4;
// Write more attributes
- TEST_THAT(write_xattr_test("testfiles/test1", "attr_2", 3427));
- TEST_THAT(write_xattr_test("testfiles/test1", "sadfohij39998.3hj", 123));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.attr_2", 947));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.sadfohij39998.3hj", 123));
// Read file attributes
x1.ReadAttributes("testfiles/test1");
@@ -352,7 +357,7 @@ int test_basics()
// Add more attributes to a file
x2.ReadAttributes("testfiles/test1");
- TEST_THAT(write_xattr_test("testfiles/test1", "328989sj..sdf", 23));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.328989sj..sdf", 23));
// Read them again, and check that the Compare() function detects that they're different
x3.ReadAttributes("testfiles/test1");
@@ -360,7 +365,7 @@ int test_basics()
TEST_THAT(!x1.Compare(x3, true, true));
// Change the value of one of them, leaving the size the same.
- TEST_THAT(write_xattr_test("testfiles/test1", "328989sj..sdf", 23));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.328989sj..sdf", 23));
x4.ReadAttributes("testfiles/test1");
TEST_THAT(!x1.Compare(x4, true, true));
}