main: fix reading xattrs longer than 256 bytes

fix reading extended attributes longer than 256 bytes.

Closes: https://github.com/containers/fuse-overlayfs/issues/284

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2021-03-21 13:54:34 +01:00
parent f6b0d2eaea
commit 11ad142525
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
2 changed files with 6 additions and 2 deletions

5
main.c
View File

@ -1373,9 +1373,10 @@ safe_read_xattr (char **ret, int sfd, const char *name, size_t initial_size)
char *tmp; char *tmp;
s = fgetxattr (sfd, name, buffer, current_size); s = fgetxattr (sfd, name, buffer, current_size);
if (s < 0) if (s >= 0 && s < current_size)
break; break;
if (s < current_size)
if (s < 0 && errno != ERANGE)
break; break;
current_size *= 2; current_size *= 2;

View File

@ -70,6 +70,9 @@ umount merged
touch lower/file-lower-layer touch lower/file-lower-layer
# set a "big" xattr
setfattr -n user.big-xattr -v "$(seq 1000 | tr -d '\n')" lower/file-lower-layer
# no upper layer # no upper layer
fuse-overlayfs -o lowerdir=lower merged fuse-overlayfs -o lowerdir=lower merged