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