hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/fs/reiserfs/xattr_security.c
....@@ -50,6 +50,7 @@
5050 int error;
5151
5252 sec->name = NULL;
53
+ sec->value = NULL;
5354
5455 /* Don't add selinux attributes on xattrs - they'll never get used */
5556 if (IS_PRIVATE(dir))
....@@ -81,11 +82,15 @@
8182 struct inode *inode,
8283 struct reiserfs_security_handle *sec)
8384 {
85
+ char xattr_name[XATTR_NAME_MAX + 1] = XATTR_SECURITY_PREFIX;
8486 int error;
85
- if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX))
87
+
88
+ if (XATTR_SECURITY_PREFIX_LEN + strlen(sec->name) > XATTR_NAME_MAX)
8689 return -EINVAL;
8790
88
- error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value,
91
+ strlcat(xattr_name, sec->name, sizeof(xattr_name));
92
+
93
+ error = reiserfs_xattr_set_handle(th, inode, xattr_name, sec->value,
8994 sec->length, XATTR_CREATE);
9095 if (error == -ENODATA || error == -EOPNOTSUPP)
9196 error = 0;
....@@ -95,7 +100,6 @@
95100
96101 void reiserfs_security_free(struct reiserfs_security_handle *sec)
97102 {
98
- kfree(sec->name);
99103 kfree(sec->value);
100104 sec->name = NULL;
101105 sec->value = NULL;