--- hplip-3.12.9/prnt/hpcups/HPCupsFilter.cpp~ 2013-02-21 17:11:06.356373425 -0500 +++ hplip-3.12.9/prnt/hpcups/HPCupsFilter.cpp 2013-02-21 17:17:44.826579491 -0500 @@ -649,20 +649,23 @@ int HPCupsFilter::processRasterData(cups { char szFileName[64]; memset(szFileName, 0, sizeof(szFileName)); - snprintf (szFileName, sizeof(szFileName), "/var/log/hp/tmp/hpcupsfilterc_%d.bmp", current_page_number); + snprintf (szFileName, sizeof(szFileName), "/var/log/hp/tmp/hpcupsfilterc_%d.bmp.XXXXXX", current_page_number); if (cups_header.cupsColorSpace == CUPS_CSPACE_RGBW || cups_header.cupsColorSpace == CUPS_CSPACE_RGB) { - cfp = fopen (szFileName, "w"); - chmod (szFileName, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd = mkstemp (szFileName); + if (fd != -1) + cfp = fdopen(fd, "w"); } if (cups_header.cupsColorSpace == CUPS_CSPACE_RGBW || cups_header.cupsColorSpace == CUPS_CSPACE_K) { - szFileName[17] = 'k'; - kfp = fopen (szFileName, "w"); - chmod (szFileName, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd; + snprintf (szFileName, sizeof(szFileName), "/tmp/hpcupsfilterk_%d.bmp.XXXXXX", current_page_number); + fd = mkstemp (szFileName); + if (fd != -1) + kfp = fdopen(fd, "w"); } WriteBMPHeader (cfp, cups_header.cupsWidth, cups_header.cupsHeight, COLOR_RASTER); --- hplip-3.12.9/prnt/hpcups/SystemServices.cpp~ 2012-09-04 08:31:10.000000000 -0400 +++ hplip-3.12.9/prnt/hpcups/SystemServices.cpp 2013-02-21 17:20:58.096677737 -0500 @@ -36,10 +36,12 @@ SystemServices::SystemServices(int iLogL m_fp = NULL; if (iLogLevel & SAVE_PCL_FILE) { + int fd; char fname[64]; - sprintf(fname, "%s/hpcups_job%d.out", "/var/log/hp/tmp",job_id); - m_fp = fopen(fname, "w"); - chmod(fname, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + sprintf(fname, "%s/hpcups_job%d.out.XXXXXX", "/var/log/hp/tmp",job_id); + fd = mkstemp (fname); + if (fd != -1) + m_fp = fdopen(fd, "w"); } } --- hplip-3.12.9/prnt/hpijs/hpijs.cpp~ 2013-02-21 17:11:06.356373425 -0500 +++ hplip-3.12.9/prnt/hpijs/hpijs.cpp 2013-02-21 17:23:08.696743534 -0500 @@ -96,14 +96,12 @@ void setLogLevel(UXServices *pSS) if (pSS->m_iLogLevel & SAVE_PCL_FILE) { + int fd; char szFileName[64]; - snprintf (szFileName,sizeof(szFileName), "/var/log/hp/tmp/hpijs_%d.out", getpid()); - - pSS->outfp = fopen (szFileName, "w"); - if (pSS->outfp) - { - chmod (szFileName, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - } + snprintf (szFileName,sizeof(szFileName), "/var/log/hp/tmp/hpijs_%d.out.XXXXXX", getpid()); + fd = mkstemp (szFileName); + if (fd != -1) + pSS->outfp = fdopen (fd, "w"); } } --- hplip-3.12.9/prnt/hpps/hppsfilter.c~ 2012-09-04 08:31:10.000000000 -0400 +++ hplip-3.12.9/prnt/hpps/hppsfilter.c 2013-02-21 17:25:50.566824441 -0500 @@ -93,10 +93,12 @@ void open_dbg_outfile(char* szjob_id) g_fp_outdbgps = NULL; if (g_savepsfile & SAVE_PS_FILE) { + int fd; char sfile_name[FILE_NAME_SIZE] = {0}; - sprintf(sfile_name, "%s/%s_%d.out",DBG_TMP_FOLDER,DBG_PSFILE, szjob_id); - g_fp_outdbgps= fopen(sfile_name, "w"); - chmod(sfile_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + sprintf(sfile_name, "%s/%s_%d.out.XXXXXX",DBG_TMP_FOLDER,DBG_PSFILE, szjob_id); + fd = mkstemp (sfile_name); + if (fd != -1) + g_fp_outdbgps= fdopen(fd, "w"); } }