lkml.org 
[lkml]   [2015]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/20] staging/lustre: fix comparison between signed and unsigned
On Sun, Feb 01, 2015 at 09:52:05PM -0500, green@linuxhacker.ru wrote:
> From: Dmitry Eremin <dmitry.eremin@intel.com>
>
> Expression if (size != (ssize_t)size) is always false.
> Therefore no bounds check errors detected.

The original code actually worked as designed. The integer overflow
could only happen on 32 bit systems and the test only was true for 32
bit systems.

> - if (size != (ssize_t)size)
> + if (size > ~((size_t)0)>>1)
> return -1;

The problem is that the code was unclear. I think the new code is even
more complicated to look at.

regards,
dan carpenter





\
 
 \ /
  Last update: 2015-02-02 14:21    [W:0.099 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site