From: Al Viro <viro@ZenIV.linux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Christoph Hellwig <hch@lst.de>, Greg KH <gregkh@suse.de>,
David Howells <dhowells@redhat.com>
Subject: Re: [RFC 01/11] add generic versions of debugfs file operations
Date: Sat, 23 Feb 2008 12:24:44 +0000 [thread overview]
Message-ID: <20080223122444.GM27894@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20080219040828.415218298@arndb.de>
On Tue, Feb 19, 2008 at 05:04:36AM +0100, Arnd Bergmann wrote:
> + char buf[3];
> + u32 *val = file->private_data;
> +
> + if (*val)
> + buf[0] = 'Y';
> + else
> + buf[0] = 'N';
> + buf[1] = '\n';
> + buf[2] = 0x00;
> + return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
Ewww - caps, \n... BTW, \0 is pointless here - simple_read_from_buffer() will
not access it with these arguments)...
> +{
> + char buf[32];
> + int buf_size;
> + u32 *val = file->private_data;
> +
> + buf_size = min(count, (sizeof(buf)-1));
> + if (copy_from_user(buf, user_buf, buf_size))
> + return -EFAULT;
> +
> + switch (buf[0]) {
> + case 'y':
> + case 'Y':
> + case '1':
> + *val = 1;
> + break;
> + case 'n':
> + case 'N':
> + case '0':
> + *val = 0;
> + break;
Please, check the length; sloppy input grammar is a bad idea. Hell, at the
very least you want -EINVAL if input is not recognized...
next prev parent reply other threads:[~2008-02-23 12:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-19 4:04 [RFC 00/11] possible debugfs/libfs consolidation Arnd Bergmann
2008-02-19 4:04 ` [RFC 01/11] add generic versions of debugfs file operations Arnd Bergmann
2008-02-23 12:24 ` Al Viro [this message]
2008-02-24 10:46 ` Arnd Bergmann
2008-02-24 18:00 ` Greg KH
2008-02-23 12:33 ` Al Viro
2008-02-19 4:04 ` [RFC 02/11] introduce simple_fs_type Arnd Bergmann
2008-02-23 12:28 ` Al Viro
2008-02-24 10:55 ` Arnd Bergmann
2008-02-19 4:04 ` [RFC 03/11] slim down debugfs Arnd Bergmann
2008-02-23 12:37 ` Al Viro
2008-02-23 19:55 ` Hugh Dickins
2008-02-24 10:59 ` Arnd Bergmann
2008-02-19 4:04 ` [RFC 04/11] slim down securityfs Arnd Bergmann
2008-02-19 4:04 ` [RFC 05/11] slim down usbfs Arnd Bergmann
2008-02-19 4:04 ` [RFC 06/11] split out linux/libfs.h from linux/fs.h Arnd Bergmann
2008-02-19 4:04 ` [RFC 07/11] split out libfs/file.c from libfs.c Arnd Bergmann
2008-02-19 4:04 ` [RFC 08/11] split out libfs/dentry.c " Arnd Bergmann
2008-02-19 4:04 ` [RFC 09/11] split out libfs/super.c " Arnd Bergmann
2008-02-19 4:04 ` [RFC 10/11] split out libfs/inode.c " Arnd Bergmann
2008-02-19 4:04 ` [RFC 11/11] split out libfs/aops.c " Arnd Bergmann
2008-02-19 16:38 ` [RFC 00/11] possible debugfs/libfs consolidation Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080223122444.GM27894@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=arnd@arndb.de \
--cc=dhowells@redhat.com \
--cc=gregkh@suse.de \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).