mode = fstat (fd, &st) != NOTOK ? (int) (st.st_mode & 0777) : m_gmprot ();
- strncpy (tmpfil, m_mktemp2(file, "annotate", NULL, &tmp), sizeof(tmpfil));
+ if ((cp = m_mktemp2(file, "annotate", NULL, &tmp)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ strncpy (tmpfil, cp, sizeof(tmpfil));
chmod (tmpfil, mode);
/*
* Make names for the temporary files.
*/
- (void)strncpy(body_file_name,
- m_mktemp2(NULL, invo_name, NULL, NULL),
- body_file_name_len);
- (void)strncpy(composition_file_name,
- m_mktemp2(NULL, invo_name, NULL, NULL),
- composition_file_name_len);
+ if ((p = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ (void)strncpy(body_file_name, p, body_file_name_len);
+ if ((p = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ unlink(body_file_name);
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ (void)strncpy(composition_file_name, p, composition_file_name_len);
if (has_body)
body_file = fopen(body_file_name, "w");
i = inplace ? msgnum + numburst : mp->hghmsg;
for (j = numburst; j >= (inplace ? 0 : 1); i--, j--) {
+ char *tempfile;
+
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, &out)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ strncpy (f2, tempfile, sizeof(f2));
strncpy (f1, m_name (i), sizeof(f1));
- strncpy (f2, m_mktemp2(NULL, invo_name, NULL, &out), sizeof(f2));
if (verbosw && i != msgnum)
printf ("message %d of digest %d becomes message %d\n", j, msgnum, i);
cp = m_mktemp2(NULL, "dist", &hdrfd, NULL);
if (cp == NULL) {
- adios("distsbr", "unable to create temporary file");
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
}
- fchmod(hdrfd, 0600);
strncpy(tmpfil, cp, sizeof(tmpfil));
if ((out = dup (hdrfd)) == NOTOK
|| (ofp = fdopen (out, "w")) == NULL)
cp = m_mktemp2(NULL, "dist", &txtfd, NULL);
if (cp == NULL) {
- adios("distsbr", "unable to create temporary file");
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
}
fchmod(txtfd, 0600);
strncpy (tmpfil, cp, sizeof(tmpfil));
}
cp = m_mktemp2(NULL, invo_name, NULL, &tmp);
- if (cp == NULL) adios("forw", "unable to create temporary file");
+ if (cp == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
strncpy (tmpfil, cp, sizeof(tmpfil));
unlink (tmpfil);
if ((in = dup (fileno (tmp))) == NOTOK)
* Process the composition file from standard input.
*/
if (compfile[0] == '-' && compfile[1] == '\0') {
+ if ((cp = m_mktemp2(NULL, invo_name, NULL, &fp)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+
/* copy standard input to temporary file */
- strncpy (infile, m_mktemp2(NULL, invo_name, NULL, &fp), sizeof(infile));
+ strncpy (infile, cp, sizeof(infile));
while (fgets (buffer, BUFSIZ, stdin))
fputs (buffer, fp);
fclose (fp);
cts[1] = NULL;
/* output MIME message to this temporary file */
- strncpy(outfile, m_mktemp2(compfile, invo_name, NULL, &fp_out),
- sizeof(outfile));
+ if ((cp = m_mktemp2(compfile, invo_name, NULL, &fp_out)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ strncpy(outfile, cp, sizeof(outfile));
unlink_outfile = 1;
/* output the message */
FILE *out;
char *cp;
- cp = m_mktemp2(NULL, invo_name, NULL, &out);
- if (cp == NULL) adios("mhbuildsbr", "unable to create temporary file");
+ if ((cp = m_mktemp2(NULL, invo_name, NULL, &out)) == NULL) {
+ adios("mhbuildsbr", "unable to create temporary file in %s",
+ get_temp_dir());
+ }
/* use a temp file to collect the plain text lines */
ce->ce_file = add (cp, NULL);
if (!(cp = ci->ci_magic))
adios (NULL, "internal error(5)");
- tfile = m_mktemp2(NULL, invo_name, NULL, NULL);
- if (tfile == NULL) {
- adios("mhbuildsbr", "unable to create temporary file");
- }
+ if ((tfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios("mhbuildsbr", "unable to create temporary file in %s",
+ get_temp_dir());
+ }
ce->ce_file = add (tfile, NULL);
ce->ce_unlink = 1;
using_stdin = 1;
if ((cp = m_mktemp2 (NULL, invo_name, &fd, NULL)) == NULL) {
- adios (NULL, "unable to create temporary file");
+ adios (NULL, "unable to create temporary file in %s",
+ get_temp_dir());
} else {
free (file);
file = add (cp, NULL);
- chmod (file, 0600);
cpydata (STDIN_FILENO, fd, "-", file);
}
modify_inplace = 1;
if ((*ctp)->c_file) {
- outfile = add (m_mktemp2 (NULL, invo_name, NULL, NULL), NULL);
+ char *tempfile;
+ if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, NULL)) == NULL) {
+ adios (NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ outfile = add (tempfile, NULL);
} else {
adios (NULL, "missing both input and output filenames\n");
}
status = NOTOK;
}
} else {
- advise (NULL, "unable to create temporary file");
+ advise (NULL, "unable to create temporary file in %s",
+ get_temp_dir());
status = NOTOK;
}
contains the decoded contents. And the decoding function, such
as openQuoted, will have set ...->ce_unlink to 1 so that it will
be unlinked by free_content (). */
- tmp_plain_file = add (m_mktemp2 (NULL, invo_name, NULL, NULL), NULL);
+ char *tempfile;
+
+ if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, NULL)) == NULL) {
+ advise (NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ tmp_plain_file = add (tempfile, NULL);
if (reformat_part (tp_part, tmp_plain_file,
tp_part->c_ctinfo.ci_type,
tp_part->c_ctinfo.ci_subtype,
decode_part (CT ct) {
char *tmp_decoded;
int status;
+ char *tempfile;
- tmp_decoded = add (m_mktemp2 (NULL, invo_name, NULL, NULL), NULL);
+ if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, NULL)) == NULL) {
+ adios (NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ tmp_decoded = add (tempfile, NULL);
/* The following call will load ct->c_cefile.ce_file with the tmp
filename of the decoded content. tmp_decoded will contain the
encoded output, get rid of that. */
if (has_crs) {
int fd;
- char *stripped_content_file =
- add (m_mktemp2 (NULL, invo_name, &fd, NULL), NULL);
+ char *stripped_content_file;
+ char *tempfile = m_mktemp2 (NULL, invo_name, &fd, NULL);
+
+ if (tempfile == NULL) {
+ adios (NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ stripped_content_file = add (tempfile, NULL);
/* Strip each CR before a LF from the content. */
fseeko (*fp, begin, SEEK_SET);
int opened_input_file = 0;
char src_buffer[BUFSIZ];
HF hf;
+ char *tempfile;
if ((conv_desc = iconv_open (dest_codeset, src_codeset)) ==
(iconv_t) -1) {
return -1;
}
- dest = add (m_mktemp2 (NULL, invo_name, &fd, NULL), NULL);
+ if ((tempfile = m_mktemp2 (NULL, invo_name, &fd, NULL)) == NULL) {
+ adios (NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ dest = add (tempfile, NULL);
if (ct->c_cefile.ce_file) {
file = &ct->c_cefile.ce_file;
if ((is_stdin = !(strcmp (file, "-")))) {
char *tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
if (tfile == NULL) {
- advise("mhparse", "unable to create temporary file");
+ advise("mhparse", "unable to create temporary file in %s",
+ get_temp_dir());
return NULL;
}
file = add (tfile, NULL);
- chmod (file, 0600);
while (fgets (buffer, sizeof(buffer), stdin))
fputs (buffer, fp);
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp2(NULL, invo_name, NULL, NULL), NULL);
+ char *tempfile;
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ ce->ce_file = add (tempfile, NULL);
ce->ce_unlink = 1;
} else {
ce->ce_file = add (*file, NULL);
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp2(NULL, invo_name, NULL, NULL), NULL);
+ char *tempfile;
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ ce->ce_file = add (tempfile, NULL);
ce->ce_unlink = 1;
} else {
ce->ce_file = add (*file, NULL);
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp2(NULL, invo_name, NULL, NULL), NULL);
+ char *tempfile;
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ ce->ce_file = add (tempfile, NULL);
ce->ce_unlink = 1;
} else {
ce->ce_file = add (*file, NULL);
ce->ce_file = add (*file, NULL);
else if (caching)
ce->ce_file = add (cachefile, NULL);
- else
- ce->ce_file = add (m_mktemp2(NULL, invo_name, NULL, NULL), NULL);
+ else {
+ char *tempfile;
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ ce->ce_file = add (tempfile, NULL);
+ }
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
}
if (*file == NULL) {
- ce->ce_file = add (m_mktemp2(NULL, invo_name, NULL, NULL), NULL);
+ char *tempfile;
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ ce->ce_file = add (tempfile, NULL);
ce->ce_unlink = 1;
} else {
ce->ce_file = add (*file, NULL);
ce->ce_file = add(*file, NULL);
else if (caching)
ce->ce_file = add(cachefile, NULL);
- else
- ce->ce_file = add(m_mktemp2(NULL, invo_name, NULL, NULL), NULL);
+ else {
+ char *tempfile;
+ if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ ce->ce_file = add (tempfile, NULL);
+ }
if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
content_error(ce->ce_file, ct, "unable to fopen for read/writing");
char *tmpfilenam, *folder;
/* Store content in temporary file for now */
- tmpfilenam = m_mktemp(invo_name, NULL, NULL);
+ if ((tmpfilenam = m_mktemp(invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
ct->c_storage = add (tmpfilenam, NULL);
/* Get the folder name */
if ((out = fopen ("/dev/null", "w")) == NULL)
adios ("/dev/null", "unable to open");
} else {
- char *cp = m_mktemp2(NULL, invo_name, NULL, &out);
- if (cp == NULL) {
- adios ("post", "unable to create temporary file");
- }
+ char *cp = m_mktemp2(NULL, invo_name, NULL, &out);
+ if (cp == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
strncpy(tmpfil, cp, sizeof(tmpfil));
- chmod (tmpfil, 0600);
}
}
FILE *out;
char *tfile = NULL, *program;
- tfile = m_mktemp2(NULL, "bccs", NULL, &out);
- if (tfile == NULL) adios("bcc", "unable to create temporary file");
+ if ((tfile = m_mktemp2(NULL, "bccs", NULL, &out)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
strncpy (bccfil, tfile, sizeof(bccfil));
fprintf (out, "From: %s\n", fullfrom);
if ((in = fopen (drft, "r")) == NULL)
adios (drft, "unable to open");
- tmpfil = m_mktemp2(NULL, invo_name, NULL, &out);
- if (tmpfil == NULL) adios("prompter", "unable to create temporary file");
- chmod (tmpfil, 0600);
+ if ((tmpfil = m_mktemp2(NULL, invo_name, NULL, &out)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
/*
* Are we changing the kill or erase character?
umask (~m_gmprot ());
- tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
- if (tfile == NULL) adios("rcvdist", "unable to create temporary file");
+ if ((tfile = m_mktemp2(NULL, invo_name, NULL, &fp)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
strncpy (tmpfil, tfile, sizeof(tmpfil));
cpydata (fileno (stdin), fileno (fp), "message", tmpfil);
fseek (fp, 0L, SEEK_SET);
- tfile = m_mktemp2(NULL, invo_name, NULL, NULL);
- if (tfile == NULL) adios("forw", "unable to create temporary file");
+ if ((tfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
strncpy (drft, tfile, sizeof(tmpfil));
rcvdistout (fp, form, addrs);
/* create a temporary file */
tmpfilenam = m_mktemp (invo_name, &fd, NULL);
if (tmpfilenam == NULL) {
- adios ("rcvstore", "unable to create temporary file");
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
}
chmod (tmpfilenam, m_gmprot());
char *nfs;
char *tfile = NULL;
- tfile = m_mktemp2(NULL, invo_name, &fd, NULL);
- if (tfile == NULL) return NOTOK;
+ if ((tfile = m_mktemp2(NULL, invo_name, &fd, NULL)) == NULL) {
+ advise(NULL, "unable to create temporary file in %s", get_temp_dir());
+ return NOTOK;
+ }
unlink (tfile);
rewind (stdin);
&& (distsw = atoi (cp))
&& altmsg) {
vec[vecp++] = "-dist";
- distfile = getcpy (m_mktemp2 (altmsg, invo_name, NULL, NULL));
+ if ((cp = m_mktemp2(altmsg, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ distfile = getcpy (cp);
unlink(distfile);
if (link (altmsg, distfile) == NOTOK) {
/* Cygwin with FAT32 filesystem produces EPERM. */
)
adios (distfile, "unable to link %s to", altmsg);
free (distfile);
- distfile = getcpy (m_mktemp2(NULL, invo_name, NULL, NULL));
+ if ((cp = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ distfile = getcpy (cp);
{
int in, out;
struct stat st;
* rename the draft file. I'm not quite sure why.
*/
if (pushsw && unique) {
- char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
- if (cp == NULL) {
- adios ("sendsbr", "unable to create temporary file");
- }
+ char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
+ if (cp == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK)
adios (file, "unable to rename %s to", drft);
drft = file;
char *cp = m_mktemp2(drft, invo_name, NULL, &out);
if (cp == NULL) {
- adios (drft, "unable to create temporary file for");
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
}
strncpy(tmpdrf, cp, sizeof(tmpdrf));
- chmod (tmpdrf, 0600);
/*
* Output the header fields
snprintf (buf, sizeof(buf), "%d", fd2);
vec[vecp++] = buf;
} else {
- admonish (NULL, "unable to create file for annotation list");
+ admonish (NULL, "unable to create temporary file in %s "
+ "for annotation list", get_temp_dir());
}
}
if (distfile && distout (drft, distfile, backup) == NOTOK)
tmp_fd (void)
{
int fd;
- char *tfile = NULL;
+ char *tfile;
- tfile = m_mktemp2(NULL, invo_name, &fd, NULL);
- if (tfile == NULL) return NOTOK;
- fchmod(fd, 0600);
+ if ((tfile = m_mktemp2(NULL, invo_name, &fd, NULL)) == NULL) return NOTOK;
if (debugsw)
advise (NULL, "temporary file %s selected", tfile);
if (debug)
debug_printf ("retrieving message from file \"%s\"\n", file);
if ((fd = copy_message (tempfd, tmpfil, 1)) == -1)
- adios (NULL, "unable to create temporary file");
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
close (tempfd);
} else {
/* getting message from stdin */
if (debug)
debug_printf ("retrieving message from stdin\n");
if ((fd = copy_message (fileno (stdin), tmpfil, 1)) == -1)
- adios (NULL, "unable to create temporary file");
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
}
if (debug)
tfile = m_mktemp2(NULL, invo_name, &fd1, NULL);
if (tfile == NULL) return -1;
- fchmod(fd1, 0600);
strncpy (tmpfil, tfile, BUFSIZ);
if (!fold) {
umask (~m_gmprot ());
- tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
- if (tfile == NULL) adios("viamail", "unable to create temporary file");
- chmod(tfile, 0600);
+ if ((tfile = m_mktemp2(NULL, invo_name, NULL, &fp)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
strncpy (tmpfil, tfile, sizeof(tmpfil));
if (!strchr(mailsw, '@'))
#endif /* not lint */
&& altmsg) {
vec[vecp++] = "-dist";
- distfile = getcpy (m_mktemp2(altmsg, invo_name, NULL, NULL));
+ if ((cp = m_mktemp2(altmsg, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+ distfile = getcpy (cp);
unlink(distfile);
if (link (altmsg, distfile) == NOTOK)
adios (distfile, "unable to link %s to", altmsg);