diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2021-04-15 19:15:00 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2021-04-15 11:37:44 -0700 |
commit | 429cad20d9e3d0b462a880351eb57b6582e44650 (patch) | |
tree | e10d90009cff836541fc6fea9c6620e54ebea8aa /contrib | |
parent | 631eea3abd793390b85883c30fceeecc17d7efe8 (diff) | |
download | ghostpdl-429cad20d9e3d0b462a880351eb57b6582e44650.tar.gz |
Solve indeterminism in pr1000_4 device.
There are 4 devices (pr201, pr1000, pr150, and pr1000_4) that are
all basically the same code. They differ in the number of lines
of data they deal with at once.
The first 3 use 24, 40 and 48 lines respectively - all numbers
that are multiples of 8. The code reads that many lines at once
and then "transposes" the data to send 'columns' of 24/40/48
pixels at once.
The pr1000_4 variant uses 60 lines. This means we read outside
the input buffer into uninitialised data.
I have my doubts that this device actually works properly, but
the change here simply bumps up the buffer sizes to be larger
and initialises it all to 0 so we get consistent SHAs in cluster
testing.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/japanese/gdevp201.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/contrib/japanese/gdevp201.c b/contrib/japanese/gdevp201.c index 1d3f4607c..c070679f3 100644 --- a/contrib/japanese/gdevp201.c +++ b/contrib/japanese/gdevp201.c @@ -130,6 +130,7 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) int height; int bits_per_column; int bytes_per_column; + int bits_per_column_rounded_up; int chunk_size; byte *in, *out; int lnum, skip; @@ -154,12 +155,17 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) height = pdev->height; bits_per_column = head_pins; bytes_per_column = bits_per_column / 8; + bits_per_column_rounded_up = (bits_per_column + 7 ) & ~7; chunk_size = bits_per_column * line_size; in = (byte *) - gs_malloc(pdev->memory->non_gc_memory, bits_per_column, line_size, "pr201_print_page(in)"); + gs_malloc(pdev->memory->non_gc_memory, + bits_per_column_rounded_up, + line_size, "pr201_print_page(in)"); out = (byte *) - gs_malloc(pdev->memory->non_gc_memory, bits_per_column, line_size, "pr201_print_page(out)"); + gs_malloc(pdev->memory->non_gc_memory, + bits_per_column_rounded_up, + line_size, "pr201_print_page(out)"); if(in == 0 || out == 0) return -1; @@ -177,6 +183,14 @@ pr201_print_page(gx_device_printer *pdev, gp_file *prn_stream) gp_fprintf(pdev->file, "\033T%d" , lr_pitch); /* 18/120 inch per line */ + if (bits_per_column_rounded_up != bits_per_column) { + memset(in + bits_per_column * line_size, 0, + (bits_per_column_rounded_up - bits_per_column) * + line_size); + memset(out, 0, + bits_per_column_rounded_up * line_size); + } + /* Send Data to printer */ lnum = 0; skip = 0; |