X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=backend%2Fdvi%2Fmdvi-lib%2Ftfmfile.c;h=8c2a30b26009aacc82601fa6e679572240e02085;hb=7aebdb8f5f4a4f44181590befdde27aac11a1e9a;hp=cab4f19dfa76fc72f79c1d06bb4b84dee5bbc80e;hpb=14def5e0c1c11cee1523e10c72df74f4cf5e451d;p=evince.git diff --git a/backend/dvi/mdvi-lib/tfmfile.c b/backend/dvi/mdvi-lib/tfmfile.c index cab4f19d..8c2a30b2 100644 --- a/backend/dvi/mdvi-lib/tfmfile.c +++ b/backend/dvi/mdvi-lib/tfmfile.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include @@ -81,7 +81,7 @@ int afm_load_file(const char *filename, TFMInfo *info) CharMetricInfo *cm; FILE *in; - in = fopen(filename, "r"); + in = fopen(filename, "rb"); if(in == NULL) return -1; status = afm_parse_file(in, &fi, P_GM); @@ -162,7 +162,7 @@ int tfm_load_file(const char *filename, TFMInfo *info) Int32 *depths; Uint32 checksum; - in = fopen(filename, "r"); + in = fopen(filename, "rb"); if(in == NULL) return -1; tfm = NULL; @@ -172,7 +172,8 @@ int tfm_load_file(const char *filename, TFMInfo *info) /* We read the entire TFM file into core */ if(fstat(fileno(in), &st) < 0) return -1; - if(st.st_size == 0) + /* according to the spec, TFM files are smaller than 16K */ + if(st.st_size == 0 || st.st_size >= 16384) goto bad_tfm; /* allocate a word-aligned buffer to hold the file */ @@ -445,7 +446,7 @@ static int ofm_load_file(const char *filename, TFMInfo *info) int olevel; int nwords; - in = fopen(filename, "r"); + in = fopen(filename, "rb"); if(in == NULL) return -1;