Browse Source

Exit upon failure to open attachment.

Error out properly if we cannot open a file to attach.
develop
Damien Goutte-Gattat 3 years ago
parent
commit
33b9b1293e
  1. 8
      src/fmail.c

8
src/fmail.c

@ -141,7 +141,9 @@ check_7bit_encoding(const char *filename)
int c, ok = 1;
unsigned n;
f = fopen(filename, "r");
if ( ! (f = fopen(filename, "r")) )
return 0; /* We'll error out later. */
while ( ! feof(f) && ! ok ) {
c = fgetc(f);
@ -609,7 +611,9 @@ process_attachment(const char *filename, magic_t ctx, FILE *out)
fprintf(out, "Content-Transfer-Encoding: %s\r\n", encoding_names[encoding]);
fprintf(out, "Content-Disposition: attachment; filename=%s\r\n\r\n", get_basename(filename));
f = fopen(filename, "r");
if ( ! (f = fopen(filename, "r")) )
err(EXIT_FAILURE, "cannot open attachment '%s'", filename);
encoding_funcs[encoding](f, out);
fclose(f);

Loading…
Cancel
Save