diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2012-03-13 22:45:00 -0700 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2012-03-15 11:54:25 +0000 |
commit | 7032257ca516060b56661fe3c711c701c2c4dfce (patch) | |
tree | 22b496f3830571d236812321fa8be59b94bc3b40 | |
parent | 61044f9a49db77b96fda45313570fc632c68b9f6 (diff) |
Fix for broken tiff devices due to use of huge signed number in overflow test
0xFFFFFFFF is used in a calculation to see how close we are to the 4G limit in
a tiff file. Problem was this was cast as a long which, in a 32 bit
system ends up being -1.
-rw-r--r-- | gs/base/gdevtsep.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gs/base/gdevtsep.c b/gs/base/gdevtsep.c index 330df2363..e413d992d 100644 --- a/gs/base/gdevtsep.c +++ b/gs/base/gdevtsep.c @@ -190,7 +190,8 @@ tiffgray_print_page(gx_device_printer * pdev, FILE * file) gx_device_tiff *const tfdev = (gx_device_tiff *)pdev; int code; - if (tfdev->Compression==COMPRESSION_NONE && pdev->height > ((long) 0xFFFFFFFF - ftell(file))/(pdev->width)) /* note width is never 0 in print_page */ + if (tfdev->Compression==COMPRESSION_NONE && + pdev->height > ((unsigned long) 0xFFFFFFFF - ftell(file))/(pdev->width)) /* note width is never 0 in print_page */ return_error(gs_error_rangecheck); /* this will overflow 32 bits */ code = gdev_tiff_begin_page(tfdev, file); @@ -355,7 +356,8 @@ tiffcmyk_print_page(gx_device_printer * pdev, FILE * file) gx_device_tiff *const tfdev = (gx_device_tiff *)pdev; int code; - if (tfdev->Compression==COMPRESSION_NONE && pdev->height > ((long) 0xFFFFFFFF - ftell(file))/(pdev->width)) /* note width is never 0 in print_page */ + if (tfdev->Compression==COMPRESSION_NONE && + pdev->height > ((unsigned long) 0xFFFFFFFF - ftell(file))/(pdev->width)) /* note width is never 0 in print_page */ return_error(gs_error_rangecheck); /* this will overflow 32 bits */ code = gdev_tiff_begin_page(tfdev, file); @@ -1582,7 +1584,8 @@ tiffsep_print_page(gx_device_printer * pdev, FILE * file) /* Write the page directory for the CMYK equivalent file. */ pdev->color_info.depth = 32; /* Create directory for 32 bit cmyk */ - if (tfdev->Compression==COMPRESSION_NONE && pdev->height > ((long) 0xFFFFFFFF - ftell(file))/(pdev->width*4)) { /* note width is never 0 in print_page */ + if (tfdev->Compression==COMPRESSION_NONE && + pdev->height > ((unsigned long) 0xFFFFFFFF - ftell(file))/(pdev->width*4)) { /* note width is never 0 in print_page */ dprintf("CMYK composite file would be too large! Reduce resolution or enable compression.\n"); return_error(gs_error_rangecheck); /* this will overflow 32 bits */ } @@ -1640,7 +1643,8 @@ tiffsep_print_page(gx_device_printer * pdev, FILE * file) pdev->color_info.depth = 8; /* Create files for 8 bit gray */ pdev->color_info.num_components = 1; - if (tfdev->Compression==COMPRESSION_NONE && pdev->height > ((long) 0xFFFFFFFF - ftell(file))/(pdev->width)) /* note width is never 0 in print_page */ + if (tfdev->Compression==COMPRESSION_NONE && + pdev->height > ((unsigned long) 0xFFFFFFFF - ftell(file))/(pdev->width)) /* note width is never 0 in print_page */ return_error(gs_error_rangecheck); /* this will overflow 32 bits */ code = tiff_set_fields_for_printer(pdev, tfdev->tiff[comp_num], 1, 0); |