deri pushed a commit to branch master in repository groff. commit 9855f8917cad578f469cdad8b976031cf49509c3 Author: Deri James <d...@chuzzlewit.myzen.co.uk> AuthorDate: Sun Jul 27 13:25:30 2025 +0100
[devpdf]: Error reporting. * src/devices/gropdf/gropdf.pl (GetType1, GetChunk): Perform rudimentary check we are given an Adobe type 1 font, and die immediately if binary format invalid. Include font filename in error messages. Fixes <https://savannah.gnu.org/bugs/?67295>. Thanks to G. Branden Robinson for report. --- ChangeLog | 12 ++++++++++++ src/devices/gropdf/gropdf.pl | 21 +++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64556f3f0..58e03a61c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2025-07-27 Deri James <d...@chuzzlewit.myzen.co.uk> + + [devpdf]: Error reporting. + + * src/devices/gropdf/gropdf.pl (GetType1, GetChunk): Perform + rudimentary check we are given an Adobe type 1 font, and die + immediately if binary format invalid. Include font filename + in error messages. + + Fixes <https://savannah.gnu.org/bugs/?67295>. Thanks to + G. Branden Robinson for report. + 2025-07-25 G. Branden Robinson <g.branden.robin...@gmail.com> * tmac/an.tmac: Refactor. diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl index bc041934a..958d54b59 100644 --- a/src/devices/gropdf/gropdf.pl +++ b/src/devices/gropdf/gropdf.pl @@ -3571,11 +3571,15 @@ sub GetType1 my $f; OpenFile(\$f,$fontdir,"$file"); - Die("unable to open font '$file' for embedding") if !defined($f); + Die("cannot open font '$file' for embedding") if !defined($f); - $head=GetChunk($f,1,"currentfile eexec"); - $body=GetChunk($f,2,"00000000") if !eof($f); - $tail=GetChunk($f,3,"cleartomark") if !eof($f); + $head=GetChunk($f,1,"currentfile eexec",$file); + + Die("'$file' not an Adobe Type 1 font") if $head!~m/^%!PS-AdobeFont-1.0:/; + Die("font format for '$file' not recognised: font header missing") if eof($f); + + $body=GetChunk($f,2,"00000000",$file); + $tail=GetChunk($f,3,"cleartomark",$file); return($head,$body,$tail); } @@ -3585,7 +3589,8 @@ sub GetChunk my $F=shift; my $segno=shift; my $ascterm=shift; - my ($type,$hdr,$chunk,@msg); + my $file=shift; + my ($type,$hdr,$chunk); binmode($F); my $enc="ascii"; @@ -3614,11 +3619,11 @@ sub GetChunk return if $chunktype == 3; $ct=read($F,$hdr,4); - Die("failed to read binary segment length") if $ct != 4; + Die("font format for '$file' not recognised: failed to read binary segment length") if $ct != 4; my $sl=unpack('V',$hdr); my $data; my $chk=read($F,$data,$sl); - Die("failed to read binary segment") if $chk != $sl; + Die("font format for '$file' not recognised: failed to read binary segment") if $chk != $sl; $chunk.=$data; } else @@ -3659,7 +3664,7 @@ sub GetChunk } else { - push(@msg,"Failed to read 2 header bytes"); + Die("font format for '$file' not recognised: failed to read 2 header bytes"); } } _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit