From 4236badf30da3ebff007ad72d91fd10e32f5c345 Mon Sep 17 00:00:00 2001 From: Martin Ebourne Date: Fri, 6 Jan 2006 16:23:32 +0000 Subject: 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. --- lib/backupclient/BackupClientFileAttributes.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') 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); -- cgit v1.2.3