summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-fops.c
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/glfs-fops.c')
-rw-r--r--api/src/glfs-fops.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index f17d7212d39..dd9becea3a4 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -2846,12 +2846,25 @@ glfs_getxattr_common (struct glfs *fs, const char *path, const char *name,
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
+ if (!name || *name == '\0') {
+ ret = -1;
+ errno = EINVAL;
+ goto out;
+ }
+
+ if (strlen(name) > GF_XATTR_NAME_MAX) {
+ ret = -1;
+ errno = ENAMETOOLONG;
+ goto out;
+ }
+
subvol = glfs_active_subvol (fs);
if (!subvol) {
ret = -1;
errno = EIO;
goto out;
}
+
retry:
if (follow)
ret = glfs_resolve (fs, subvol, path, &loc, &iatt, reval);
@@ -2916,6 +2929,18 @@ pub_glfs_fgetxattr (struct glfs_fd *glfd, const char *name, void *value,
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs);
+ if (!name || *name == '\0') {
+ ret = -1;
+ errno = EINVAL;
+ goto out;
+ }
+
+ if (strlen(name) > GF_XATTR_NAME_MAX) {
+ ret = -1;
+ errno = ENAMETOOLONG;
+ goto out;
+ }
+
subvol = glfs_active_subvol (glfd->fs);
if (!subvol) {
ret = -1;
@@ -3109,12 +3134,25 @@ glfs_setxattr_common (struct glfs *fs, const char *path, const char *name,
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
+ if (!name || *name == '\0') {
+ ret = -1;
+ errno = EINVAL;
+ goto out;
+ }
+
+ if (strlen(name) > GF_XATTR_NAME_MAX) {
+ ret = -1;
+ errno = ENAMETOOLONG;
+ goto out;
+ }
+
subvol = glfs_active_subvol (fs);
if (!subvol) {
ret = -1;
errno = EIO;
goto out;
}
+
retry:
if (follow)
ret = glfs_resolve (fs, subvol, path, &loc, &iatt, reval);
@@ -3184,6 +3222,18 @@ pub_glfs_fsetxattr (struct glfs_fd *glfd, const char *name, const void *value,
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs);
+ if (!name || *name == '\0') {
+ ret = -1;
+ errno = EINVAL;
+ goto out;
+ }
+
+ if (strlen(name) > GF_XATTR_NAME_MAX) {
+ ret = -1;
+ errno = ENAMETOOLONG;
+ goto out;
+ }
+
subvol = glfs_active_subvol (glfd->fs);
if (!subvol) {
ret = -1;