[Mesa-dev] [PATCH 1/3] gallium/os: Fix overflow on 32 bits
Marek Olšák
maraeo at gmail.com
Sat Oct 8 11:13:11 UTC 2016
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Thu, Oct 6, 2016 at 7:51 PM, Axel Davy <axel.davy at ens.fr> wrote:
> On systems with more than 4GB of ram,
> os_get_total_physical_memory was triggering an integer
> overflow for the linux and haiku path, when on
> 32 bits.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94561
>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
> ---
> src/gallium/auxiliary/os/os_misc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c
> index 82e4957..5e2bedc 100644
> --- a/src/gallium/auxiliary/os/os_misc.c
> +++ b/src/gallium/auxiliary/os/os_misc.c
> @@ -128,7 +128,7 @@ os_get_total_physical_memory(uint64_t *size)
> const long phys_pages = sysconf(_SC_PHYS_PAGES);
> const long page_size = sysconf(_SC_PAGE_SIZE);
>
> - *size = phys_pages * page_size;
> + *size = (int64_t)phys_pages * (int64_t)page_size;
> return (phys_pages > 0 && page_size > 0);
> #elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD)
> size_t len = sizeof(*size);
> @@ -153,7 +153,7 @@ os_get_total_physical_memory(uint64_t *size)
> status_t ret;
>
> ret = get_system_info(&info);
> - *size = info.max_pages * B_PAGE_SIZE;
> + *size = (int64_t)info.max_pages * (int64_t)B_PAGE_SIZE;
> return (ret == B_OK);
> #elif defined(PIPE_OS_WINDOWS)
> MEMORYSTATUSEX status;
> --
> 2.10.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list