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]
Date:	Fri, 11 Jan 2013 15:21:55 +0100
From:	Michal Nazarewicz <mina86@...a86.com>
To:	Minchan Kim <minchan@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	Minchan Kim <minchan@...nel.org>, Mel Gorman <mgorman@...e.de>,
	Andy Whitcroft <apw@...dowen.org>,
	Alexander Nyberg <alexn@....su.se>,
	Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH v2 1/2] Fix wrong EOF compare

On Fri, Jan 11 2013, Minchan Kim <minchan@...nel.org> wrote:
> The C standards allows the character type char to be singed or unsinged,
> depending on the platform and compiler. Most of systems uses signed char,
> but those based on PowerPC and ARM processors typically use unsigned char.
> This can lead to unexpected results when the variable is used to compare
> with EOF(-1). It happens my ARM system and this patch fixes it.
>
> Cc: Mel Gorman <mgorman@...e.de>
> Cc: Andy Whitcroft <apw@...dowen.org>
> Cc: Alexander Nyberg <alexn@....su.se>
> Cc: Michal Nazarewicz <mina86@...a86.com>

Acked-by: Michal Nazarewicz <mina86@...a86.com>

> Cc: Randy Dunlap <rdunlap@...radead.org>
> Signed-off-by: Minchan Kim <minchan@...nel.org>
> ---
>  Documentation/page_owner.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/page_owner.c b/Documentation/page_owner.c
> index f0156e1..43dde96 100644
> --- a/Documentation/page_owner.c
> +++ b/Documentation/page_owner.c
> @@ -32,12 +32,13 @@ int read_block(char *buf, FILE *fin)
>  {
>  	int ret = 0;
>  	int hit = 0;
> +	int val;
>  	char *curr = buf;
>  
>  	for (;;) {
> -		*curr = getc(fin);
> -		if (*curr == EOF) return -1;
> -
> +		val = getc(fin);
> +		if (val == EOF) return -1;
> +		*curr = val;
>  		ret++;
>  		if (*curr == '\n' && hit == 1)
>  			return ret - 1;

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@...gle.com>--------------ooO--(_)--Ooo--

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ