I have found that pdf2swf is unable to handle some PDF files because the size
of the VectorGraphicOutputDev::states stack is too small. In addition, the code
in VectorGraphicOutputDev::saveState which attempts to check for this condition
is incorrect and causes a buffer-overrun problem. I have made some changes to
VectorGraphicOutputDev.{cc,h} to dynamically allocate the states stack and I
wish to submit them for incorporation into swftools.
thanks/jeff
*** swftools-0.9.2/lib/pdf/VectorGraphicOutputDev.cc.orig 2011-10-06
23:20:17.000000000 -0400
--- swftools-0.9.2/lib/pdf/VectorGraphicOutputDev.cc 2014-04-17
11:16:29.167097700 -0400
***************
*** 110,116 ****
this->char_output_dev.drawchar = drawchar_callback;
this->char_output_dev.addfont = addfont_callback;
! memset(states, 0, sizeof(states));
};
void VectorGraphicOutputDev::setParameter(const char*key, const char*value)
--- 110,118 ----
this->char_output_dev.drawchar = drawchar_callback;
this->char_output_dev.addfont = addfont_callback;
! statelen = 64;
! states = new GFXOutputState[statelen];
! memset(states, 0, sizeof(GFXOutputState)*statelen);
};
void VectorGraphicOutputDev::setParameter(const char*key, const char*value)
***************
*** 659,664 ****
--- 661,667 ----
{
finish();
delete charDev;charDev=0;
+ delete [] states; states=0;
};
GBool VectorGraphicOutputDev::upsideDown()
{
***************
*** 887,897 ****
msg("<trace> saveState %p", state);
updateAll(state);
! if(statepos>=64) {
! msg("<fatal> Too many nested states in pdf.");
! exit(1);
}
- statepos ++;
states[statepos].state = state;
states[statepos].createsoftmask = states[statepos-1].createsoftmask;
states[statepos].transparencygroup = states[statepos-1].transparencygroup;
--- 890,910 ----
msg("<trace> saveState %p", state);
updateAll(state);
! statepos++;
! /*
! * Check if the size of the stack of state objects needs to be increased.
! * Note that state[0] is used by beginPage.
! */
! if (statepos >= statelen) {
! int newstatelen = statelen+64;
! msg("<trace> saveState increasing statelen from %i to %i", statelen,
newstatelen);
! GFXOutputState *newstates = new GFXOutputState[newstatelen];
! memcpy(newstates, states, sizeof(GFXOutputState)*statelen);
! memset(newstates+statelen, 0,
sizeof(GFXOutputState)*(newstatelen-statelen));
! delete [] states;
! states = newstates;
! statelen = newstatelen;
}
states[statepos].state = state;
states[statepos].createsoftmask = states[statepos-1].createsoftmask;
states[statepos].transparencygroup = states[statepos-1].transparencygroup;
*** swftools-0.9.2/lib/pdf/VectorGraphicOutputDev.h.orig 2011-10-06
23:20:17.000000000 -0400
--- swftools-0.9.2/lib/pdf/VectorGraphicOutputDev.h 2014-04-17
11:18:14.302597700 -0400
***************
*** 184,190 ****
int currentpage;
char outer_clip_box; //whether the page clip box is still on
! GFXOutputState states[64];
int statepos;
int type3active; // are we between beginType3()/endType3()?
--- 184,197 ----
int currentpage;
char outer_clip_box; //whether the page clip box is still on
! GFXOutputState *states;
! /*
! * statelen is the number of elements allocated in the states array.
! */
! int statelen;
! /*
! * statepos is the index of the current element in the states array.
! */
int statepos;
int type3active; // are we between beginType3()/endType3()?
---------------
SWFTools-common is a self-managed list. To subscribe/unsubscribe, or amend an
existing subscription, please kindly point your favourite web browser
at:<http://lists.nongnu.org/mailman/listinfo/swftools-common>