summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/socket.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/net/socket.c b/net/socket.c
index a1bd16106625..9b3dca699a3d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -469,27 +469,15 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
469static ssize_t sockfs_getxattr(struct dentry *dentry, struct inode *inode, 469static ssize_t sockfs_getxattr(struct dentry *dentry, struct inode *inode,
470 const char *name, void *value, size_t size) 470 const char *name, void *value, size_t size)
471{ 471{
472 const char *proto_name; 472 if (!strcmp(name, XATTR_NAME_SOCKPROTONAME)) {
473 size_t proto_size;
474 int error;
475
476 error = -ENODATA;
477 if (!strncmp(name, XATTR_NAME_SOCKPROTONAME, XATTR_NAME_SOCKPROTONAME_LEN)) {
478 proto_name = dentry->d_name.name;
479 proto_size = strlen(proto_name);
480
481 if (value) { 473 if (value) {
482 error = -ERANGE; 474 if (dentry->d_name.len + 1 > size)
483 if (proto_size + 1 > size) 475 return -ERANGE;
484 goto out; 476 memcpy(value, dentry->d_name.name, dentry->d_name.len + 1);
485
486 strncpy(value, proto_name, proto_size + 1);
487 } 477 }
488 error = proto_size + 1; 478 return dentry->d_name.len + 1;
489 } 479 }
490 480 return -EOPNOTSUPP;
491out:
492 return error;
493} 481}
494 482
495static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer, 483static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,