public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Arkadiusz Miśkiewicz" <arekm@maven.pl>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] Validate string -> number conversion.
Date: Thu, 26 Aug 2010 18:26:12 +1000	[thread overview]
Message-ID: <20100826082612.GE705@dastard> (raw)
In-Reply-To: <1282807852-23457-1-git-send-email-arekm@maven.pl>

On Thu, Aug 26, 2010 at 09:30:52AM +0200, Arkadiusz Miśkiewicz wrote:
> Make sure that numbers passed as string will fit into proper
> types when doing string->uid_t/gid_t/prid_t conversion.
> 
> Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>

Looks good, but just a couple of minor style things:

> ---
> 
> Fixed version.
> 
>  libxcmd/input.c |   33 +++++++++++++++++++++------------
>  quota/project.c |    2 +-
>  2 files changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/libxcmd/input.c b/libxcmd/input.c
> index 1bc0745..d0c4e0d 100644
> --- a/libxcmd/input.c
> +++ b/libxcmd/input.c
> @@ -336,16 +336,19 @@ prid_from_string(
>  	char		*project)
>  {
>  	fs_project_t	*prj;
> -	prid_t		prid;
> +	unsigned long int	prid_long;
>  	char		*sp;

unsigned long is all that is necessary here - that will also keep
the same indent as well.
>  
>  	/*
>  	 * Allow either a full numeric or a valid projectname, even
>  	 * if it starts with a digit.
>  	 */
> -	prid = (prid_t)strtoul(project, &sp, 10);
> -	if (*project != '\0' && *sp == '\0')
> -		return prid;
> +	prid_long = strtoul(project, &sp, 10);
> +	if (*project != '\0' && *sp == '\0') {
> +		if ((prid_long == ULONG_MAX && errno == ERANGE) || (prid_long > (prid_t)-1))

Can you split this to keep within 80 chars?

Same for the uid and gid checks as well.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2010-08-26  8:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25  8:22 [PATCH] Validate string -> number conversion Arkadiusz Miśkiewicz
2010-08-25  8:45 ` Arkadiusz Miskiewicz
2010-08-25  9:01   ` Arkadiusz Miskiewicz
2010-08-26  8:42     ` Dave Chinner
2010-08-27 22:31       ` [PATCH] xfstests: Quota project id setting overflow Arkadiusz Miśkiewicz
2010-08-26  7:30 ` [PATCH] Validate string -> number conversion Arkadiusz Miśkiewicz
2010-08-26  8:26   ` Dave Chinner [this message]
2010-08-27 20:54     ` [PATCH] Validate string -> number conversion. [version 3] Arkadiusz Miśkiewicz
2010-08-27 21:32       ` Alex Elder
2010-09-01 10:19       ` Christoph Hellwig

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=20100826082612.GE705@dastard \
    --to=david@fromorbit.com \
    --cc=arekm@maven.pl \
    --cc=xfs@oss.sgi.com \
    /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