]> www.fi.muni.cz Git - evince.git/commitdiff
backends: Fix several security issues in the dvi-backend.
authorJosé Aliste <jaliste@src.gnome.org>
Tue, 7 Dec 2010 18:56:47 +0000 (15:56 -0300)
committerJosé Aliste <jaliste@src.gnome.org>
Wed, 5 Jan 2011 13:12:49 +0000 (10:12 -0300)
See CVE-2010-2640, CVE-2010-2641, CVE-2010-2642 and  CVE-2010-2643.

backend/dvi/mdvi-lib/afmparse.c
backend/dvi/mdvi-lib/dviread.c
backend/dvi/mdvi-lib/pk.c
backend/dvi/mdvi-lib/tfmfile.c
backend/dvi/mdvi-lib/vf.c

index 164366b03dd0b19bb8271e8a03775782b550eccd..361e23d6ce1a1ab1d5f36b494966ac53b271ebf4 100644 (file)
@@ -160,7 +160,7 @@ static char *token(FILE *stream)
     
     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);
index cd8cfa916113e821e87c344de300ba998a8b95a5..d01432056518ac6ae3518ed3eec5f5705159f02f 100644 (file)
@@ -1507,6 +1507,10 @@ int      special(DviContext *dvi, int opcode)
        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;
index a5791869af1f36b9e0dd1ba890ce1cf2858dba85..08377e634b151b64dcb427911c6a9ce9b8d4345a 100644 (file)
@@ -469,6 +469,15 @@ static int pk_load_font(DviParams *unused, DviFont *font)
                        }
                        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)
@@ -512,7 +521,7 @@ static int pk_load_font(DviParams *unused, DviFont *font)
        }
 
        /* 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,
index 73ebf26a91a9eba0d6e42277484e2e399612517b..8c2a30b26009aacc82601fa6e679572240e02085 100644 (file)
@@ -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 */
index fb4984766e72ef4a32d436a983d329dda8cb6c73..a5ae3bbe721a162c7f486eddca85c08fccac2893 100644 (file)
@@ -165,6 +165,12 @@ static int vf_load_font(DviParams *params, DviFont *font)
                        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)