Re: Fixing a long standing bug in view.c

Hello, Philipp!

> view.c erroneously assumes it can easily malloc a file if mmap failed and
> passes view->s.st_size to g_malloc. But if largefile support has been enabled,
> view->s.st_size is a 64 bit value and thus possibly exceeds the limit of
> gulong which g_malloc takes for size. This patch fixes it.

I've applied a much simple patch for this:

/* Make sure view->s.st_size is not truncated when passed to g_malloc */
if ((gulong) view->s.st_size == view->s.st_size)
    view->data = (unsigned char *) g_malloc ((gulong) view->s.st_size);

Thank you for reporting the problem!

Pavel Roskin

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]