diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2017-01-18 18:16:57 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2017-01-18 18:16:57 +0000 |
commit | c9bf8148044f38aa1b093a96c88a309afb86592c (patch) | |
tree | f2df9dfed56c94a53d9e96d2c7d789ddfeb96cae /sys/ufs | |
parent | 4a42ab7ddab29949f4c54bea34241997ffdf6a8d (diff) | |
download | src-c9bf8148044f38aa1b093a96c88a309afb86592c.tar.gz src-c9bf8148044f38aa1b093a96c88a309afb86592c.zip |
restore(8): Handle extended attribute names correctly
UFS2 extended attribute names are not NUL-terminated. Handle
appropriately.
Correct the EXTATTR_BASE_LENGTH() macro, which handled ea_namelength ==
one (mod eight) extended attributes incorrectly.
PR: 216127
Reported by: dewayne at heuristicsystems.com.au
Reviewed by: kib@
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D9208
Notes
Notes:
svn path=/head/; revision=312393
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ufs/extattr.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/ufs/ufs/extattr.h b/sys/ufs/ufs/extattr.h index 52207e9a0593..73f97556c6e4 100644 --- a/sys/ufs/ufs/extattr.h +++ b/sys/ufs/ufs/extattr.h @@ -93,12 +93,14 @@ struct extattr { * content referenced by eap. */ #define EXTATTR_NEXT(eap) \ - ((struct extattr *)(((void *)(eap)) + (eap)->ea_length)) -#define EXTATTR_CONTENT(eap) (((void *)(eap)) + EXTATTR_BASE_LENGTH(eap)) + ((struct extattr *)(((u_char *)(eap)) + (eap)->ea_length)) +#define EXTATTR_CONTENT(eap) \ + (void *)(((u_char *)(eap)) + EXTATTR_BASE_LENGTH(eap)) #define EXTATTR_CONTENT_SIZE(eap) \ ((eap)->ea_length - EXTATTR_BASE_LENGTH(eap) - (eap)->ea_contentpadlen) +/* -1 below compensates for ea_name[1] */ #define EXTATTR_BASE_LENGTH(eap) \ - ((sizeof(struct extattr) + (eap)->ea_namelength + 7) & ~7) + roundup2((sizeof(struct extattr) - 1 + (eap)->ea_namelength), 8) #ifdef _KERNEL |