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