From: Davi Arnaut <davi.arnaut@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATH 0/2] strndup_user, description
Date: Wed, 15 Feb 2006 07:42:37 -0300 [thread overview]
Message-ID: <20060215074237.cec92f44.davi.arnaut@gmail.com> (raw)
In-Reply-To: <1139971990.14831.2.camel@localhost.localdomain>
On Wed, 15 Feb 2006 02:53:10 +0000
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> On Maw, 2006-02-14 at 21:47 -0300, Davi Arnaut wrote:
> > This patch series creates a strndup_user() function in order to avoid duplicated
> > and error-prone (userspace modifying the string after the strlen_user()) code.
>
> Well userspace can still modify in this case. So you could still get a
> \0 mid buffer but that seems harmless.
Yes.
> However
>
> > +#define strdup_user(s) strndup_user(s, PAGE_SIZE)
>
> Better this doesn't exist as it is a wrapper for a bad habit that isnt
> yet used so why encourage it.
>
Ok, I will inline it.
>
> > + length = strlen_user(s);
>
> What if n is very large ? Should use strnlen_user clipped by n
That's what "if (length > n) length = n" is for.
> Also say the length limit is 8 and the text is "hello\0"
>
> We get length = 5 5 < 8, alloc 5 bytes set 5th to \0 and return "hell
> \0"
No, we would get length = 6, strlen_user returns the size of the string
_including_ the terminating NUL.
--
Davi Arnaut
prev parent reply other threads:[~2006-02-15 9:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-15 0:47 [PATH 0/2] strndup_user, description Davi Arnaut
2006-02-15 2:53 ` Alan Cox
2006-02-15 10:42 ` Davi Arnaut [this message]
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=20060215074237.cec92f44.davi.arnaut@gmail.com \
--to=davi.arnaut@gmail.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.