]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: check attribute name validity
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)
committerEric Sandeen <sandeen@redhat.com>
Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)
Source kernel commit: 654805367d982cffdb9979453673aab9c3c96d07

Check extended attribute entry names for invalid characters.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr.c
libxfs/xfs_attr.h

index 95f040b8d61f723fc9e64a659ca14bebce87bf01..b88383023d6912bb1e6b1e935b45b985a7eb764a 100644 (file)
@@ -1331,3 +1331,20 @@ xfs_attr_node_get(xfs_da_args_t *args)
        xfs_da_state_free(state);
        return retval;
 }
+
+/* Returns true if the attribute entry name is valid. */
+bool
+xfs_attr_namecheck(
+       const void      *name,
+       size_t          length)
+{
+       /*
+        * MAXNAMELEN includes the trailing null, but (name/length) leave it
+        * out, so use >= for the length check.
+        */
+       if (length >= MAXNAMELEN)
+               return false;
+
+       /* There shouldn't be any nulls here */
+       return !memchr(name, 0, length);
+}
index bdf52a333f3f9a2d7d4492d54b0ecf9a919402a5..2297d84676669ff25aaad45f86686e6671a1d182 100644 (file)
@@ -145,6 +145,6 @@ int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags);
 int xfs_attr_remove_args(struct xfs_da_args *args);
 int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
                  int flags, struct attrlist_cursor_kern *cursor);
-
+bool xfs_attr_namecheck(const void *name, size_t length);
 
 #endif /* __XFS_ATTR_H__ */