nfsd: properly handle embedded newlines in fault_injection input
authorJeff Layton <jlayton@primarydata.com>
Wed, 18 Jun 2014 19:00:19 +0000 (15:00 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 23 Jun 2014 15:31:38 +0000 (11:31 -0400)
Currently rpc_pton() fails to handle the case where you echo an address
into the file, as it barfs on the newline. Ensure that we NULL out the
first occurrence of any newline.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/fault_inject.c

index 2ed05c3cd43dee7459b0bec809a1b61800aeebe3..f1333fc35b3305976d15b718b45418dd1bd7a52c 100644 (file)
@@ -115,11 +115,19 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
        struct net *net = current->nsproxy->net_ns;
        struct sockaddr_storage sa;
        u64 val;
+       char *nl;
 
        if (copy_from_user(write_buf, buf, size))
                return -EFAULT;
        write_buf[size] = '\0';
 
+       /* Deal with any embedded newlines in the string */
+       nl = strchr(write_buf, '\n');
+       if (nl) {
+               size = nl - write_buf;
+               *nl = '\0';
+       }
+
        size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
        if (size > 0)
                nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);
This page took 0.025174 seconds and 5 git commands to generate.