lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6D8AEE2@saturn3.aculab.com>
Date:	Fri, 25 Nov 2011 09:46:09 -0000
From:	"David Laight" <David.Laight@...LAB.COM>
To:	"Hagen Paul Pfeifer" <hagen@...u.net>, <netdev@...r.kernel.org>
Cc:	"Stephen Hemminger" <shemminger@...tta.com>
Subject: RE: [PATCH iproute2 1/2] utils: add s32 parser

> +int get_s32(__s32 *val, const char *arg, int base)
> +{
> +	long res;
> +	char *ptr;
> +
> +	if (!arg || !*arg)
> +		return -1;

No need to check *arg, picked up below.

> +	res = strtoul(arg, &ptr, base);
> +	if (!ptr || ptr == arg || *ptr || res > INT32_MAX || res <
INT32_MIN)

No need to check !ptr.

> +		return -1;
> +	*val = res;
> +	return 0;
> +}

Seems to me this be commoned with get_s16() by using
a function that takes the bounds as parameters.
Or possibly with a wrapper to strtoul() that does all the
validation checks.

	David



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ