Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!usc!snorkelwacker!bloom-beacon!MITVMA.MIT.EDU!brossard%litsun.epfl.ch From: brossard%litsun.epfl.ch@MITVMA.MIT.EDU (Alain Brossard) Newsgroups: comp.windows.x Subject: (bug) in appres.c Message-ID: <9004120727.AA15162@litsun.litsun.epfl.ch> Date: 12 Apr 90 07:27:29 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 72 CC'ed to xpert to avoid bug fixes hoarding by constructors 1/2 :-). Alain Brossard brossard@litsun.epfl.ch X Window System Bug Report xbugs@expo.lcs.mit.edu VERSION: R4 CLIENT MACHINE and OPERATING SYSTEM: Sun 3/60 running SunOS 4.0.3 AREA: appres, appres.c SYNOPSIS: For some reason or other, appres started dumping core on me last night. I had used it about 30 times without problems when it started failing. It completly stopped working on that one machine, but still worked fine on all the others. The problem was traced to the mktemp call and an extra ~ at the end of the pattern. Starting some time last night, mktemp started returning "" as a the resulting pattern, this made the subsequent fopen call fail and as it's return code isn't checked the following fget fails with a segmentation fault. REPEAT BY: If you can repeat this, you might send a bug report to SUN :-) SAMPLE FIX: *** /tmp/,RCSt1a15888 Thu Apr 12 09:20:36 1990 --- appres.c Thu Apr 12 09:12:42 1990 *************** *** 77,89 **** &argc, argv); if (argc != 1) usage (); ! strcpy (tmpbuf, "/tmp/ar.XXXXXX~"); mktemp (tmpbuf); unlink (tmpbuf); XrmPutFileDatabase (XtDatabase(XtDisplay(toplevel)), tmpbuf); ! fp = fopen (tmpbuf, "r"); unlink (tmpbuf); printit = False; incont = False; --- 77,94 ---- &argc, argv); if (argc != 1) usage (); ! strcpy (tmpbuf, "/tmp/ar.XXXXXX"); mktemp (tmpbuf); unlink (tmpbuf); XrmPutFileDatabase (XtDatabase(XtDisplay(toplevel)), tmpbuf); ! if( !(fp = fopen (tmpbuf, "r"))) { ! char error[180]; ! sprintf( error, "Appres: error opening tmp file `%s'", tmpbuf ); ! perror( error ); ! exit( 1 ); ! } unlink (tmpbuf); printit = False; incont = False;