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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190408095540.GG9224@smile.fi.intel.com>
Date:   Mon, 8 Apr 2019 12:55:40 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Yury Norov <yury.norov@...il.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Arnd Bergmann <arnd@...db.de>,
        Kees Cook <keescook@...omium.org>,
        Matthew Wilcox <willy@...radead.org>,
        Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        Mike Travis <travis@....com>, Yury Norov <ynorov@...vell.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/5] lib: rework bitmap_parselist

On Fri, Apr 05, 2019 at 08:32:08PM +0300, Yury Norov wrote:
> Remove __bitmap_parselist helper and split the function to logical
> parts.

> +static const char *bitmap_getnum(const char *str, unsigned int *num)
> +{
> +	unsigned int n = 0, _num = 0;
> +
> +	if (!isdigit(*str))
> +		return ERR_PTR(-EINVAL);
> +
> +	for (; isdigit(*str); str++) {
> +		_num = _num * 10 + (*str - '0');
> +		if (_num < n)
> +			return ERR_PTR(-EOVERFLOW);
> +
> +		n = _num;
> +	}
> +
> +	*num = _num;
> +
> +	return str;
> +}

This looks like (semi) open coded simple_strtoull()

unsigned long long _num;
char *endp;

_num = simple_strtoull(str, &endp, 10);
if (endp == str)
	return ERR_PTR(-EINVAL);
if (_num > UINT_MAX || (endp - str) > 10)
	return ERR_PTR(-EOVERFLOW);
*num = _num;
return endp;

> +static inline bool end_of_str(char c)
> +{
> +	return c == '\0' || c == '\n';
> +}

This reminds me a check at the end of _kstrtoull(). Can we use same approach in
both cases?

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ