Commit ef439da3 authored by Mike DePaulo's avatar Mike DePaulo Committed by Mike Gabriel

CVE-2014-0210: unvalidated length fields in fs_read_list() from…

CVE-2014-0210: unvalidated length fields in fs_read_list() from xorg/lib/libXfont commit 5fa73ac18474be3032ee7af9c6e29deab163ea39 fs_read_list() parses a reply from the font server. The reply contains a list of strings with embedded length fields, none of which are validated. This can cause out of bound reads when looping over the strings in the reply.
parent ece51493
...@@ -2365,6 +2365,7 @@ fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec) ...@@ -2365,6 +2365,7 @@ fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
FSBlockedListPtr blist = (FSBlockedListPtr) blockrec->data; FSBlockedListPtr blist = (FSBlockedListPtr) blockrec->data;
fsListFontsReply *rep; fsListFontsReply *rep;
char *data; char *data;
long dataleft; /* length of reply left to use */
int length, int length,
i, i,
ret; ret;
...@@ -2382,16 +2383,30 @@ fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec) ...@@ -2382,16 +2383,30 @@ fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
return AllocError; return AllocError;
} }
data = (char *) rep + SIZEOF (fsListFontsReply); data = (char *) rep + SIZEOF (fsListFontsReply);
dataleft = (rep->length << 2) - SIZEOF (fsListFontsReply);
err = Successful; err = Successful;
/* copy data into FontPathRecord */ /* copy data into FontPathRecord */
for (i = 0; i < rep->nFonts; i++) for (i = 0; i < rep->nFonts; i++)
{ {
if (dataleft < 1)
break;
length = *(unsigned char *)data++; length = *(unsigned char *)data++;
dataleft--; /* used length byte */
if (length > dataleft) {
#ifdef DEBUG
fprintf(stderr,
"fsListFonts: name length (%d) > dataleft (%ld)\n",
length, dataleft);
#endif
err = BadFontName;
break;
}
err = AddFontNamesName(blist->names, data, length); err = AddFontNamesName(blist->names, data, length);
if (err != Successful) if (err != Successful)
break; break;
data += length; data += length;
dataleft -= length;
} }
_fs_done_read (conn, rep->length << 2); _fs_done_read (conn, rep->length << 2);
return err; return err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment