path: root/lib/backupclient/BackupClientFileAttributes.cpp
diff options
authorMartin Ebourne <>2006-01-06 16:23:32 +0000
committerMartin Ebourne <>2006-01-06 16:23:32 +0000
commit4236badf30da3ebff007ad72d91fd10e32f5c345 (patch)
treea0099674f09f3d396811d85deaa47592b4d25d3d /lib/backupclient/BackupClientFileAttributes.cpp
parent18d03eb51a36ad7d31edace38cff956e90f3fa19 (diff)
Fixes for xattr on Linux
- A very unlikely failure where getxattr returns an error code the first time but succeeds the second time could cause buffer overrun and corruption. Affecting the tests only: - On Linux (and presumably Irix) normal users can only modify attributes in the 'user.' namespace. - Some filesystems can have strict limits on value size (eg. 1024 bytes on ext3 depending on block size) - ENOATTR is defined in xattr/xattr.h. This file is an optional install and is not needed for the rest of box to use extended attributes. Provide it ourselves if not present.
Diffstat (limited to 'lib/backupclient/BackupClientFileAttributes.cpp')
1 files changed, 4 insertions, 1 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
@@ -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);
THROW_EXCEPTION(CommonException, OSFileError);