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, 20 Apr 2012 16:03:37 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Xi Wang <xi.wang@...il.com>
Cc:	linux-kernel@...r.kernel.org, Alex Elder <elder@...amhost.com>,
	David Airlie <airlied@...ux.ie>,
	Pekka Enberg <penberg@...nel.org>
Subject: Re: [RFC][PATCH] introduce SIZE_MAX

On Thu, 19 Apr 2012 00:27:51 -0400
Xi Wang <xi.wang@...il.com> wrote:

> ULONG_MAX is often used to check for integer overflow when calculating
> allocation size.  While ULONG_MAX happens to work on most systems,
> there is no guarantee that `size_t' must be the same size as `long'.
> 
> This patch introduces SIZE_MAX, the maximum value of `size_t', to
> improve portability and readability for allocation size validation.
>
> ...
>
> @@ -331,7 +331,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
>  
>  	/* alloc new snap context */
>  	err = -ENOMEM;
> -	if (num > (ULONG_MAX - sizeof(*snapc)) / sizeof(u64))
> +	if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64))
>  		goto fail;
>  	snapc = kzalloc(sizeof(*snapc) + num*sizeof(u64), GFP_NOFS);
>  	if (!snapc)

hm, yes, I suppose that's better - hardwiring the assumption that
size_t has type unsigned long is pretty ugly.

Will we need something for ssize_t also?
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ