Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita518b74

Browse files
authored
Merge pull request#20642 from meeseeksmachine/auto-backport-of-pr-20629-on-v3.4.x
Backport PR#20629 on branch v3.4.x (Add protection against out-of-bounds read in ttconv)
2 parents0a9139e +649c07d commita518b74

File tree

3 files changed

+21228
-27
lines changed

3 files changed

+21228
-27
lines changed

‎extern/ttconv/pprdrv_tt.cpp

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -798,33 +798,36 @@ void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
798798
** Find the tables we want and store there vital
799799
** statistics in tables[].
800800
*/
801-
for (x=0; x <9; x++ )
802-
{
803-
do
804-
{
805-
diff =strncmp( (char*)ptr, table_names[x],4 );
806-
807-
if ( diff >0 )/* If we are past it.*/
808-
{
809-
tables[x].length =0;
810-
diff =0;
811-
}
812-
elseif ( diff <0 )/* If we haven't hit it yet.*/
813-
{
814-
ptr +=16;
815-
}
816-
elseif ( diff ==0 )/* Here it is!*/
817-
{
818-
tables[x].newoffset = nextoffset;
819-
tables[x].checksum =getULONG( ptr +4 );
820-
tables[x].oldoffset =getULONG( ptr +8 );
821-
tables[x].length =getULONG( ptr +12 );
822-
nextoffset += ( ((tables[x].length +3) /4) *4 );
823-
count++;
824-
ptr +=16;
825-
}
826-
}
827-
while (diff !=0);
801+
ULONG num_tables_read =0;/* Number of tables read from the directory*/
802+
for (x =0; x <9; x++) {
803+
do {
804+
if (num_tables_read < font->numTables) {
805+
/* There are still tables to read from ptr*/
806+
diff =strncmp((char*)ptr, table_names[x],4);
807+
808+
if (diff >0) {/* If we are past it.*/
809+
tables[x].length =0;
810+
diff =0;
811+
}elseif (diff <0) {/* If we haven't hit it yet.*/
812+
ptr +=16;
813+
num_tables_read++;
814+
}elseif (diff ==0) {/* Here it is!*/
815+
tables[x].newoffset = nextoffset;
816+
tables[x].checksum =getULONG( ptr +4 );
817+
tables[x].oldoffset =getULONG( ptr +8 );
818+
tables[x].length =getULONG( ptr +12 );
819+
nextoffset += ( ((tables[x].length +3) /4) *4 );
820+
count++;
821+
ptr +=16;
822+
num_tables_read++;
823+
}
824+
}else {
825+
/* We've read the whole table directory already*/
826+
/* Some tables couldn't be found*/
827+
tables[x].length =0;
828+
break;/* Proceed to next tables[x]*/
829+
}
830+
}while (diff !=0);
828831

829832
}/* end of for loop which passes over the table directory*/
830833

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp