summaryrefslogtreecommitdiff
path: root/fonttools
diff options
context:
space:
mode:
authorpfaedit <pfaedit>2006-04-06 17:17:13 +0000
committerpfaedit <pfaedit>2006-04-06 17:17:13 +0000
commit8f2dfb27ed3a8a38c6e0e680bb96f1b856d8a0ae (patch)
treef123ab48fe882dc50cfbf534e0dcea8c3894adae /fonttools
parent0b18c19eb78ca74c5fb49745663898e1c14f32cb (diff)
The PLRM says that formfeed is white space. The t1_spec says that formfeed is not whitespace. The t1_spec wins after eexec.
Diffstat (limited to 'fonttools')
-rw-r--r--fonttools/pfadecrypt.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/fonttools/pfadecrypt.c b/fonttools/pfadecrypt.c
index 3b3089fb..35d1e4e9 100644
--- a/fonttools/pfadecrypt.c
+++ b/fonttools/pfadecrypt.c
@@ -310,26 +310,27 @@ return( 1 );
static int nrandombytes[4];
#define EODMARKLEN 16
-static void decrypteexec(FILE *in,FILE *temp, int hassectionheads) {
+#define bgetc(extra,in) (*(extra)=='\0' ? getc(in) : (unsigned char ) *(extra)++ )
+static void decrypteexec(FILE *in,FILE *temp, int hassectionheads, char *extra) {
int ch1, ch2, ch3, ch4, binary;
int zcnt;
unsigned char zeros[EODMARKLEN+6+1];
int sect_len;
- while ( (ch1=getc(in))!=EOF && isspace(ch1));
+ while ( (ch1=bgetc(extra,in))!=EOF && (ch1==' ' || ch1=='\t' || ch1=='\n' || ch1=='\r'));
/* Mac POST resources also have 6 bytes inserted here. They appear to be */
/* a four byte length followed by ^B ^@ */
if ( ch1==0200 && hassectionheads ) {
/* skip the 6 byte section header in pfb files that follows eexec */
- ch1 = getc(in);
- sect_len = getc(in);
- sect_len |= getc(in)<<8;
- sect_len |= getc(in)<<16;
- sect_len |= getc(in)<<24;
+ ch1 = bgetc(extra,in);
+ sect_len = bgetc(extra,in);
+ sect_len |= bgetc(extra,in)<<8;
+ sect_len |= bgetc(extra,in)<<16;
+ sect_len |= bgetc(extra,in)<<24;
sect_len -= 3;
- ch1 = getc(in);
+ ch1 = bgetc(extra,in);
}
- ch2 = getc(in); ch3 = getc(in); ch4 = getc(in);
+ ch2 = bgetc(extra,in); ch3 = bgetc(extra,in); ch4 = bgetc(extra,in);
binary = 0;
if ( ch1<'0' || (ch1>'9' && ch1<'A') || ( ch1>'F' && ch1<'a') || (ch1>'f') ||
ch2<'0' || (ch2>'9' && ch2<'A') || (ch2>'F' && ch2<'a') || (ch2>'f') ||
@@ -347,15 +348,15 @@ return;
nrandombytes[2] = decode(ch3);
nrandombytes[3] = decode(ch4);
zcnt = 0;
- while (( ch1=getc(in))!=EOF ) {
+ while (( ch1=bgetc(extra,in))!=EOF ) {
--sect_len;
if ( hassectionheads ) {
if ( sect_len==0 && ch1==0200 ) {
- ch1 = getc(in);
- sect_len = getc(in);
- sect_len |= getc(in)<<8;
- sect_len |= getc(in)<<16;
- sect_len |= getc(in)<<24;
+ ch1 = bgetc(extra,in);
+ sect_len = bgetc(extra,in);
+ sect_len |= bgetc(extra,in)<<8;
+ sect_len |= bgetc(extra,in)<<16;
+ sect_len |= bgetc(extra,in)<<24;
sect_len += 1;
if ( ch1=='\1' )
break;
@@ -376,13 +377,13 @@ return;
} else {
nrandombytes[0] = decode(hex(ch1,ch2));
nrandombytes[1] = decode(hex(ch3,ch4));
- ch1 = getc(in); ch2 = getc(in); ch3 = getc(in); ch4 = getc(in);
+ ch1 = bgetc(extra,in); ch2 = bgetc(extra,in); ch3 = bgetc(extra,in); ch4 = bgetc(extra,in);
nrandombytes[2] = decode(hex(ch1,ch2));
nrandombytes[3] = decode(hex(ch3,ch4));
zcnt = 0;
- while (( ch1=getc(in))!=EOF ) {
- while ( ch1!=EOF && isspace(ch1)) ch1 = getc(in);
- while ( (ch2=getc(in))!=EOF && isspace(ch2));
+ while (( ch1=bgetc(extra,in))!=EOF ) {
+ while ( ch1!=EOF && isspace(ch1)) ch1 = bgetc(extra,in);
+ while ( (ch2=bgetc(extra,in))!=EOF && isspace(ch2));
if ( ch1=='0' && ch2=='0' ) ++zcnt; else { dumpzeros(temp,zeros,zcnt); zcnt = 0;}
if ( zcnt>EODMARKLEN )
break;
@@ -392,7 +393,7 @@ return;
zeros[zcnt-1] = decode(hex(ch1,ch2));
}
}
- while (( ch1=getc(in))=='0' || isspace(ch1) );
+ while (( ch1=bgetc(extra,in))=='0' || isspace(ch1) );
if ( ch1!=EOF ) ungetc(ch1,in);
}
@@ -510,6 +511,8 @@ return;
break;
if ( strstr(buffer,"(Binary)")!=NULL && strstr(buffer, "StartData")!=NULL )
break;
+ if ( strstr(buffer,"Blend")!=NULL )
+ mightbegsf = 0;
if ( mightbegsf ) {
if ( strstr(buffer,"/Private")!=NULL || strstr(buffer,"/Subrs")!=NULL ||
strstr(buffer,"/CharStrings")!=NULL )
@@ -521,7 +524,7 @@ return;
}
if ( strstr(buffer,"currentfile")!=NULL && strstr(buffer, "eexec")!=NULL ) {
- decrypteexec(in,temp,hassectionheads);
+ decrypteexec(in,temp,hassectionheads,strstr(buffer, "eexec")+5);
rewind(temp);
decryptagain(temp,out);
} else if ( strstr(buffer,"(Binary)")!=NULL && strstr(buffer, "StartData")!=NULL ) {