See CVE-2010-2640, CVE-2010-2641, CVE-2010-2642 and CVE-2010-2643.
idx = 0;
while (ch != EOF && ch != ' ' && ch != lineterm
- && ch != '\t' && ch != ':' && ch != ';')
+ && ch != '\t' && ch != ':' && ch != ';' && idx < MAX_NAME)
{
ident[idx++] = ch;
ch = fgetc(stream);
Int32 arg;
arg = dugetn(dvi, opcode - DVI_XXX1 + 1);
+ if (arg <= 0) {
+ dvierr(dvi, _("malformed special length\n"));
+ return -1;
+ }
s = mdvi_malloc(arg + 1);
dread(dvi, s, arg);
s[arg] = 0;
}
if(feof(p))
break;
+
+ /* Although the PK format support bigger char codes,
+ * XeTeX and other extended TeX engines support charcodes up to
+ * 65536, while normal TeX engine supports only charcode up to 255.*/
+ if (cc < 0 || cc > 65536) {
+ mdvi_error (_("%s: unexpected charcode (%d)\n"),
+ font->fontname,cc);
+ goto error;
+ }
if(cc < loc)
loc = cc;
if(cc > hic)
}
/* resize font char data */
- if(loc > 0 || hic < maxch-1) {
+ if(loc > 0 && hic < maxch-1) {
memmove(font->chars, font->chars + loc,
(hic - loc + 1) * sizeof(DviFontChar));
font->chars = xresize(font->chars,
/* 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 */
cc = fuget1(p);
tfm = fuget3(p);
}
+ if (cc < 0 || cc > 65536) {
+ /* TeX engines do not support char codes bigger than 65535 */
+ mdvi_error(_("(vf) %s: unexpected character %d\n"),
+ font->fontname, cc);
+ goto error;
+ }
if(loc < 0 || cc < loc)
loc = cc;
if(hic < 0 || cc > hic)