Bug 541614 (CVE-2009-4035) - CVE-2009-4035 xpdf: buffer overflow in FoFiType1::parse
Summary: CVE-2009-4035 xpdf: buffer overflow in FoFiType1::parse
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2009-4035
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard: impact=important,source=vendorsec,pub...
Depends On: 543489 543490 543491 543492 543494 543495
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-11-26 13:57 UTC by Tomas Hoger
Modified: 2019-06-08 12:52 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-12-16 10:53:54 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2009:1680 normal SHIPPED_LIVE Important: xpdf security update 2009-12-16 10:21:31 UTC
Red Hat Product Errata RHSA-2009:1681 normal SHIPPED_LIVE Important: gpdf security update 2009-12-16 10:11:14 UTC
Red Hat Product Errata RHSA-2009:1682 normal SHIPPED_LIVE Important: kdegraphics security update 2009-12-16 10:35:06 UTC

Description Tomas Hoger 2009-11-26 13:57:10 UTC
SuSE reported a buffer overflow in FoFiType1::parse affecting older xpdf versions.  Code snippets from fofi/FoFiType1.cc:

 133 void FoFiType1::parse() {
 ...
 163       line = getNextLine(line);
 164       for (j = 0; j < 300 && line; ++j) {
 165         line1 = getNextLine(line);
 166         if ((n = line1 - line) > 255) {
 167           n = 255;
 168         }
 169         strncpy(buf, line, n);

getNextLine can, however, return NULL:

 117 char *FoFiType1::getNextLine(char *line) {
 118   while (line < (char *)file + len && *line != '\x0a' && *line != '\x0d') {
 119     ++line;
 120   }
 121   if (line < (char *)file + len && *line == '\x0d') {
 122     ++line;
 123   }
 124   if (line < (char *)file + len && *line == '\x0a') {
 125     ++line;
 126   }
 127   if (line >= (char *)file + len) {
 128     return NULL;
 129   }

Therefore, (line1 - line) is not defined / results in negative value n.  That value is later passed to strncpy, causing overflow of buf buffer.

Comment 2 Tomas Hoger 2009-11-26 14:05:43 UTC
This problem seems to be fixed upstream already.  line1 = getNextLine was made part of the for loop control condition, next iteration is not executed when line1 is NULL:

http://cgit.freedesktop.org/poppler/poppler/diff/fofi/FoFiType1.cc?id=4b4fc5c0

This change is part of the commit:

http://cgit.freedesktop.org/poppler/poppler/commit/?id=4b4fc5c0

which suggests xpdf was fixed upstream in between version 3.00 and 3.01.

Older xpdf versions (2.x) have similar code in xpdf/FontFile.cc, Type1FontFile::Type1FontFile, but the nextLine there does not return NULL.

Comment 10 Tomas Hoger 2009-12-16 09:46:58 UTC
Lifting embargo.

Comment 11 errata-xmlrpc 2009-12-16 10:35:20 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 4

Via RHSA-2009:1680 https://rhn.redhat.com/errata/RHSA-2009-1680.html

Comment 12 errata-xmlrpc 2009-12-16 10:35:23 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 4

Via RHSA-2009:1681 https://rhn.redhat.com/errata/RHSA-2009-1681.html

Comment 13 errata-xmlrpc 2009-12-16 10:35:26 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 4

Via RHSA-2009:1682 https://rhn.redhat.com/errata/RHSA-2009-1682.html


Note You need to log in before you can comment on or make changes to this bug.