Fix some tempnam/tmpnam usages

This commit is contained in:
angelos 1998-06-19 17:34:55 +00:00
parent d80b84a3a7
commit 93d15a7f33
3 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,37 @@
*** src/delegate.c.orig Thu Jun 18 17:47:28 1998
--- src/delegate.c Thu Jun 18 17:54:08 1998
***************
*** 205,211 ****
subcontract (struct file_job * fjob, buffer_t * buffer,
struct delegation * contractor)
{
! char * command, * stdin_content_filename = NULL;
FILE * in_stream, * out_stream;
int lines_read = 0;
char buf[512];
--- 205,211 ----
subcontract (struct file_job * fjob, buffer_t * buffer,
struct delegation * contractor)
{
! char * command, stdin_content_filename[40];
FILE * in_stream, * out_stream;
int lines_read = 0;
char buf[512];
***************
*** 220,226 ****
if (fjob->name == job->stdin_filename) /* not strcmp */
{
/* Dump the content of the buffer */
! stdin_content_filename = tmpnam (NULL);
buffer_save (buffer, stdin_content_filename);
/* We change the name of the file so that the correct
--- 220,227 ----
if (fjob->name == job->stdin_filename) /* not strcmp */
{
/* Dump the content of the buffer */
! snprintf(stdin_content_filename, 40, "%s/a2p.XXXXXXXX", P_tmpdir);
! close(mkstemp(stdin_content_filename));
buffer_save (buffer, stdin_content_filename);
/* We change the name of the file so that the correct

View File

@ -0,0 +1,27 @@
*** src/main.c.orig Thu Jun 18 17:54:14 1998
--- src/main.c Thu Jun 18 17:55:12 1998
***************
*** 603,613 ****
{
#define PREFIX "% "
FILE * tmp_file;
! char * tmp_filename;
char buf [BUFSIZ];
! tmp_filename = tmpnam (NULL);
! tmp_file = fopen (tmp_filename, "w");
if (!tmp_file)
error (1, errno, _("cannot open file `%s'"), tmp_filename);
--- 603,613 ----
{
#define PREFIX "% "
FILE * tmp_file;
! char tmp_filename[40];
char buf [BUFSIZ];
! snprintf(tmp_filename, 40, "%s/a2ps.XXXXXXXX", P_tmpdir);
! tmp_file = fdopen (mkstemp(tmp_filename), "w");
if (!tmp_file)
error (1, errno, _("cannot open file `%s'"), tmp_filename);

View File

@ -0,0 +1,37 @@
*** src/generate.c.orig Thu Jun 18 19:21:32 1998
--- src/generate.c Thu Jun 18 19:26:31 1998
***************
*** 83,89 ****
struct file_job * file_job;
struct stat statbuf; /* to get file modification time */
struct tm *tm;
! char * sample_file = NULL; /* the name of the file on which run file(1) */
a2ps_open_input_session (job, name);
file_job = CURRENT_FILE (job);
--- 83,89 ----
struct file_job * file_job;
struct stat statbuf; /* to get file modification time */
struct tm *tm;
! char sample_file[40]; /* the name of the file on which run file(1) */
a2ps_open_input_session (job, name);
file_job = CURRENT_FILE (job);
***************
*** 96,102 ****
/* Create the buffer in charge of stdin */
buffer_stream_set (res, stdin, end_of_line);
/* Ask it to make a sample of the file */
! sample_file = tmpnam (NULL);
buffer_sample_get (res, sample_file);
}
else
--- 96,103 ----
/* Create the buffer in charge of stdin */
buffer_stream_set (res, stdin, end_of_line);
/* Ask it to make a sample of the file */
! snprintf(sample_file, 40, "%s/a2ps.XXXXXXXX", P_tmpdir);
! close(mkstemp(sample_file));
buffer_sample_get (res, sample_file);
}
else