Bug 691390 - Valgrind reports Invalid write in names_trace_finish (iname.c:424)
Summary: Valgrind reports Invalid write in names_trace_finish (iname.c:424)
Status: RESOLVED DUPLICATE of bug 691005
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: master
Hardware: PC Linux
: P4 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-14 04:52 UTC by D. Wagner
Modified: 2010-06-14 15:17 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Postscript file that triggers Invalid write (988.15 KB, application/postscript)
2010-06-14 04:52 UTC, D. Wagner
Details
Valgrind output for fe1af3.ps (6.61 KB, text/plain)
2010-06-14 04:55 UTC, D. Wagner
Details
Somewhat smaller file that appears to trigger the same Invalid write (166.53 KB, application/postscript)
2010-06-14 04:55 UTC, D. Wagner
Details
Valgrind output for smaller.ps (6.62 KB, text/plain)
2010-06-14 04:56 UTC, D. Wagner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description D. Wagner 2010-06-14 04:52:20 UTC
Created attachment 6369 [details]
Postscript file that triggers Invalid write

If I run gs -sDEVICE=laserjet on the attached file (fe1af3.ps) with valgrind, valgrind reports an Invalid read and Invalid write error in names_trace_finish (iname.c:424).  The code appears to be accessing memory after it was freed.

Invalid write errors and use-after-free errors sometimes indicate a security vulnerability.

To reproduce:

valgrind --track-origins=yes --read-var-info=yes --suppressions=afgs-source/gs/toolbin/vg_bugs.supp --suppressions=afgs-source/gs/toolbin/vg_okay.supp afgs-source/gs/bin/gs.debug -q -dNOPAUSE -dBATCH -sDEVICE=laserjet -sOutputFile=/dev/null fe1af3.ps > vg_fe1af3.out 2>&1

I've attached the problematic Postscript file (fe1af3.ps) as well as Valgrind's output (vg_fe1af3.out).

This test case also finds some possibly-new Valgrind warnings associated with use of uninitialized values.  I don't know whether they matter.

I've also attached a somewhat smaller file (smaller.ps) that triggers the same Invalid write error, and a file with Valgrind's output on this smaller file (vg_smaller.out).  The smaller file was generated using an automatic testcase minimization tool I wrote for Postscript files.

This is confirmed in Subversion revision 11345.
Comment 1 D. Wagner 2010-06-14 04:55:17 UTC
Created attachment 6370 [details]
Valgrind output for fe1af3.ps
Comment 2 D. Wagner 2010-06-14 04:55:51 UTC
Created attachment 6371 [details]
Somewhat smaller file that appears to trigger the same Invalid write
Comment 3 D. Wagner 2010-06-14 04:56:37 UTC
Created attachment 6372 [details]
Valgrind output for smaller.ps
Comment 4 Ken Sharp 2010-06-14 06:58:23 UTC
This looks to be the same issue as 691005, but may be easier to debug this one.
Comment 5 Alex Cherepanov 2010-06-14 15:17:49 UTC
I've reproduced this problem on amd64 GNU/Linux box with the following
command line:

valgrind gs/debugobj/gs -o /dev/null -dNOGC -sDEVICE=nullpage smaller.ps

So far I was unable to reproduce this bug on i686 GNU/Linux system.

*** This bug has been marked as a duplicate of bug 691005 ***