diff options
author | Ken Sharp <Ken.Sharp@artifex.com> | 2025-08-22 16:45:06 +0100 |
---|---|---|
committer | Ken Sharp <Ken.Sharp@artifex.com> | 2025-08-22 16:45:06 +0100 |
commit | bf531986b6d053b8221f0b7d7646a6f40ea68db3 (patch) | |
tree | e67a9f404de2747432eb58e65f4d6ee12ac7dd17 | |
parent | 7fd8251568ae2cee46d5762dc2e54ae9d2dca463 (diff) |
Bug #708768 "Global-buffer-underread due to missing check when using okiibm output device"
As noted in the bug report, some resolutions (roughly 0-30 and 150-210
assuming rounding) are invalid, this is signalled with a '-1' in the
graphics_modes_9 table. But the selected mode is never actually tested
to see if it is valid....
Check the selected mode, return an error if it is invalid. As an extra,
check the Y resolution too and throw an error if it is neitehr 72 nor
144 as these are the only supported resolutions.
-rw-r--r-- | devices/gdevokii.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/devices/gdevokii.c b/devices/gdevokii.c index 461ca98b7..9cafe924f 100644 --- a/devices/gdevokii.c +++ b/devices/gdevokii.c @@ -118,6 +118,9 @@ okiibm_print_page1(gx_device_printer *pdev, gp_file *prn_stream, int y_9pin_high if (x_dpi / 60 >= sizeof(graphics_modes_9)/sizeof(graphics_modes_9[0])) { return_error(gs_error_rangecheck); } + if (pdev->HWResolution[1] != 72 && pdev->HWResolution[1] != 144) + return_error(gs_error_configurationerror); + in_y_mult = (y_9pin_high ? 2 : 1); line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev); /* Note that in_size is a multiple of 8. */ @@ -128,6 +131,9 @@ okiibm_print_page1(gx_device_printer *pdev, gp_file *prn_stream, int y_9pin_high out = buf2; out_y_mult = 1; start_graphics = graphics_modes_9[x_dpi / 60]; + if (start_graphics < 0) + return_error(gs_error_configurationerror); + first_pass = (start_graphics == 3 ? 1 : 0); last_pass = first_pass * 2; y_passes = (y_9pin_high ? 2 : 1); |