if (!tgt || !src)
return -1;
- char tmp[PATH_MAX];
struct Body *b = NULL;
-
bool use_disp;
+ struct Buffer *tmp = mutt_buffer_pool_get();
if (src->filename)
{
use_disp = true;
- mutt_str_strfcpy(tmp, src->filename, sizeof(tmp));
+ mutt_buffer_strcpy(tmp, src->filename);
}
else
{
use_disp = false;
- tmp[0] = '\0';
}
- mutt_adv_mktemp(tmp, sizeof(tmp));
- if (mutt_save_attachment(fp, src, tmp, MUTT_SAVE_NO_FLAGS, NULL) == -1)
+ mutt_buffer_adv_mktemp(tmp);
+ if (mutt_save_attachment(fp, src, mutt_b2s(tmp), MUTT_SAVE_NO_FLAGS, NULL) == -1)
+ {
+ mutt_buffer_pool_release(&tmp);
return -1;
+ }
*tgt = mutt_body_new();
b = *tgt;
b->parts = NULL;
b->next = NULL;
- b->filename = mutt_str_strdup(tmp);
+ b->filename = mutt_str_strdup(mutt_b2s(tmp));
b->use_disp = use_disp;
b->unlink = true;
}
mutt_stamp_attachment(b);
-
+ mutt_buffer_pool_release(&tmp);
return 0;
}
struct Email *e, bool resend)
{
struct Message *msg = NULL;
- char file[PATH_MAX];
struct Body *b = NULL;
FILE *fp_body = NULL;
int rc = -1;
s.fp_in = fp_body;
+ struct Buffer *file = mutt_buffer_pool_get();
+
/* create temporary files for all attachments */
for (b = newhdr->content; b; b = b->next)
{
/* what follows is roughly a receive-mode variant of
* mutt_get_tmp_attachment () from muttlib.c */
- file[0] = '\0';
+ mutt_buffer_reset(file);
if (b->filename)
{
- mutt_str_strfcpy(file, b->filename, sizeof(file));
+ mutt_buffer_strcpy(file, b->filename);
b->d_filename = mutt_str_strdup(b->filename);
}
else
mutt_param_delete(&b->parameter, "x-mutt-noconv");
}
- mutt_adv_mktemp(file, sizeof(file));
- s.fp_out = mutt_file_fopen(file, "w");
+ mutt_buffer_adv_mktemp(file);
+ s.fp_out = mutt_file_fopen(mutt_b2s(file), "w");
if (!s.fp_out)
goto bail;
if (mutt_file_fclose(&s.fp_out) != 0)
goto bail;
- mutt_str_replace(&b->filename, file);
+ mutt_str_replace(&b->filename, mutt_b2s(file));
b->unlink = true;
mutt_stamp_attachment(b);
bail:
/* that's it. */
+ mutt_buffer_pool_release(&file);
if (fp_body != fp)
mutt_file_fclose(&fp_body);
if (msg)