[gs-cvs] rev 8814 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Tue Jul 1 03:22:27 PDT 2008
Author: leonardo
Date: 2008-07-01 03:22:25 -0700 (Tue, 01 Jul 2008)
New Revision: 8814
Modified:
trunk/gs/src/gdevp14.c
trunk/gs/src/gstparam.h
Log:
Fix (clist writer) : The maximal compositor command size was wrong.
DETAILS :
Bug 689927 "rangecheck in c_pdf14trans_write() causing 'unregistered' error".
The bug was introduced in revision 8587.
See comments in code.
Thanks to Ray and Marcos for participation.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevp14.c
===================================================================
--- trunk/gs/src/gdevp14.c 2008-06-30 23:56:04 UTC (rev 8813)
+++ trunk/gs/src/gdevp14.c 2008-07-01 10:22:25 UTC (rev 8814)
@@ -2927,19 +2927,16 @@
{
const gs_pdf14trans_params_t * pparams = &((const gs_pdf14trans_t *)pct)->params;
int need, avail = *psize;
- /* Must be large enough for largest data struct */
- byte buf[25 /* See sput_matrix. */ +
- 21 + sizeof(pparams->Background)
- + sizeof(pparams->GrayBackground) + sizeof(pparams->bbox)
- + sizeof(cdev->mask_id)];
+ byte buf[MAX_CLIST_TRANSPARENCY_BUFFER_SIZE]; /* Must be large enough
+ to fit the data written below. We don't implement a dynamic check for the buffer owerflow,
+ assuming that the consistency is verified in the coding phase.
+ See the definition of MAX_CLIST_TRANSPARENCY_BUFFER_SIZE. */
byte * pbuf = buf;
int opcode = pparams->pdf14_op;
int mask_size = 0;
uint mask_id = 0;
int code;
- /* Write PDF 1.4 compositor data into the clist */
-
*pbuf++ = opcode; /* 1 byte */
switch (opcode) {
default: /* Should not occur. */
Modified: trunk/gs/src/gstparam.h
===================================================================
--- trunk/gs/src/gstparam.h 2008-06-30 23:56:04 UTC (rev 8813)
+++ trunk/gs/src/gstparam.h 2008-07-01 10:22:25 UTC (rev 8814)
@@ -123,7 +123,23 @@
byte transfer_fn[MASK_TRANSFER_FUNCTION_SIZE];
} gx_transparency_mask_params_t;
-#define MAX_CLIST_COMPOSITOR_SIZE (sizeof( gx_transparency_mask_params_t ) + 1)
+/*
+ The longest compositor command includes transparency mask parameters
+ (see gdevp14.c c_pdf14trans_write() the "case PDF14_BEGIN_TRANS_MASK").
+ Note that 'idle' is not written because it is generated by the clist interpreter.
+*/
+#define MAX_CLIST_TRANSPARENCY_BUFFER_SIZE ( \
+ 4 /* the clist cmd prefix byte cmd_opv_extend + extended function + 2 bytes for band_id */ + \
+ 1 + sizeof(float) * 6 /* See sput_matrix. */ + \
+ sizeof(((gs_pdf14trans_params_t *)0)->subtype) + \
+ 3 /* replacing, function_is_identity, Background_components */ + \
+ sizeof(((gs_pdf14trans_params_t *)0)->bbox) + \
+ sizeof(((gs_pdf14trans_params_t *)0)->mask_id) + \
+ sizeof(((gs_pdf14trans_params_t *)0)->Background) + \
+ sizeof(((gs_pdf14trans_params_t *)0)->GrayBackground))
+#define MAX_CLIST_TRANSPARENCY_COMPOSITOR_SIZE (MAX_CLIST_TRANSPARENCY_BUFFER_SIZE + \
+ sizeof(((gs_pdf14trans_params_t *)0)->transfer_fn))
+#define MAX_CLIST_COMPOSITOR_SIZE MAX_CLIST_TRANSPARENCY_COMPOSITOR_SIZE
/* Select the opacity or shape parameters. */
typedef enum {
More information about the gs-cvs
mailing list