[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m3lji5xdcm.fsf@hase.home>
Date: Tue, 17 Nov 2009 18:36:41 +0100
From: Andreas Schwab <schwab@...hat.com>
To: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Cc: linux-kernel@...r.kernel.org, Michael Buesch <mb@...sch.de>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] strcmp: fix overflow error
Uwe Kleine-König <u.kleine-koenig@...gutronix.de> writes:
> strcmp("\x01", "\xef") returns 18 but it should return something < 0.
> The reason is that the variable holding the result of the subtraction is
> too small and overflows.
When char is signed strcmp("\xef", "\x01") still returns something < 0.
You need to cast to unsigned char first.
Andreas.
--
Andreas Schwab, schwab@...hat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists