Path: blob/main/mail/bulk_mailer/files/patch-bulk_mailer.c
16461 views
--- ./bulk_mailer.c.orig 2000-05-24 21:34:33.000000000 +02001+++ ./bulk_mailer.c 2013-10-01 12:36:24.324624000 +02002@@ -95,11 +95,16 @@3#include <sysexits.h>4#include <errno.h>5#include <time.h>6+#include <unistd.h>7+#include <stdlib.h>8#ifdef HAVE_STRING_H9#include <string.h>10#endif11#include "patchlevel.h"1213+#define COMMAND_BUF_SIZE (32*1024)14+#define DATEBUF_SIZE (100)15+16#ifndef PIPECOMMAND17#define PIPECOMMAND "/usr/lib/sendmail -bs %s"18#endif19@@ -122,9 +127,11 @@20char *strchr();21char *strrchr();22#endif23+#ifndef __FreeBSD__24char *malloc ();25char *realloc ();26char *mktemp ();27+#endif2829/*30* (default) max different domains per envelope.31@@ -238,7 +245,7 @@3233static char *34realloc_or_else (oldbuf, size)35-char *oldbuf;36+void *oldbuf;37int size;38{39char *result;40@@ -296,6 +303,7 @@41* memory, appending a NUL to the copy.42*/4344+/*45static char *46strndup (str, len)47char *str;48@@ -307,6 +315,7 @@49result[len] = '\0';50return result;51}52+*/5354/*55* sort by case-folded reversed domain56@@ -337,15 +346,15 @@57{58char *at;59char *ptr;60- char *domain;61+/* char *domain; */62char tempbuf[1024];63- char c;64+/* char c; */6566/*67* make sure there's room in the buffer.68*/69if (num_addrs >= num_addr_slots) {70- struct address *new;71+/* struct address *new; */7273num_addr_slots += 1000;74if (address_list == NULL)75@@ -571,12 +580,12 @@76open_envelope ()77{78FILE *fp;79- char command_buf[32*1024];80+ char command_buf[COMMAND_BUF_SIZE];8182if (debug_flag)83fp = stderr;84else {85- sprintf (command_buf, PIPECOMMAND, sendmail_flags);86+ snprintf (command_buf, COMMAND_BUF_SIZE, PIPECOMMAND, sendmail_flags);8788if ((fp = popen (command_buf, "w")) == NULL) {89fprintf (stderr, "can't open pipe to sendmail: %s\n",90@@ -927,7 +936,7 @@91{92struct tm gmt;93struct tm *lt;94- static char datebuf[100];95+ static char datebuf[DATEBUF_SIZE];96int gmtoff;97char sign;98static char *months[] = {99@@ -960,7 +969,7 @@100sign = '-';101gmtoff = -gmtoff;102}103- sprintf (datebuf, "%s, %d %s %04d %02d:%02d:%02d %c%02d%02d",104+ snprintf (datebuf, DATEBUF_SIZE, "%s, %d %s %04d %02d:%02d:%02d %c%02d%02d",105wdays[lt->tm_wday], lt->tm_mday, months[lt->tm_mon], lt->tm_year + 1900,106lt->tm_hour, lt->tm_min, lt->tm_sec,107sign,108@@ -985,7 +994,7 @@109copy_message (out, in)110FILE *out, *in;111{112- int c;113+/* int c; */114char linebuf[32*1024];115int has_valid_approved_hdr = 0;116int has_resent_to_hdr = 0;117@@ -1218,14 +1227,14 @@118*/119lines = 0;120while (fgets (linebuf, sizeof (linebuf), in) != NULL) {121- if (lines < 5 &&122+ if (lines < 5 && (123/*124* these often occur in English-text unsubscribe requests125*/126contains (linebuf, "delete me") ||127contains (linebuf, "remove me") ||128contains (linebuf, "subscribe") ||129- contains (linebuf, "unsubscribe"))130+ contains (linebuf, "unsubscribe")))131saw_command = 1;132++lines;133fputs (linebuf, out);134@@ -1326,13 +1335,14 @@135int argc;136char *argv[];137{138- int i;139+/* int i; */140FILE *fp;141FILE *tmp;142static char template[] = "/tmp/blkXXXXXX";143char *tempname;144- int c;145- char buf[1024];146+/* int c; */147+/* char buf[1024]; */148+ int fd;149150while (argc > 1 && (*argv[1] == '-' || *argv[1] == '+')) {151if (strcmp (argv[1], "-comment") == 0 && argc > 2) {152@@ -1513,8 +1523,9 @@153exit (EX_OSFILE);154}155156- tempname = mktemp (template);157- tmp = fopen (template, "w");158+ fd = mkstemp (template);159+ tempname = template;160+ tmp = fdopen (fd, "w+");161switch (copy_message (tmp, stdin)) {162163case HAS_EMBEDDED_COMMAND:164@@ -1592,4 +1603,5 @@165166exit (EX_OK);167}168+ exit (EX_OK);169}170171172