summaryrefslogtreecommitdiff
path: root/libexec/spamd
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-12-30 22:05:58 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-12-30 22:05:58 +0000
commit2622aabf199bc79809a1ebc2f1c54a3af40af336 (patch)
tree78e47947180c8f49e542e96ea693fad44941e346 /libexec/spamd
parent4f79c8980ab9ef986acbdbcffd3a5bcbb6fff964 (diff)
dynamically allocate the struct con[], according to the -c arg given or a default, being the max 200
Diffstat (limited to 'libexec/spamd')
-rw-r--r--libexec/spamd/spamd.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index 5faadd1b61c..b5f4d5cb683 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.5 2002/12/26 01:12:24 mickey Exp $ */
+/* $OpenBSD: spamd.c,v 1.6 2002/12/30 22:05:57 mickey Exp $ */
/*
* Copyright (c) 2002 Theo de Raadt. All rights reserved.
@@ -76,7 +76,7 @@ struct con {
char obuf[8192];
char *op;
int ol;
-} con[MAXCON];
+} *con;
void
usage(void)
@@ -344,9 +344,6 @@ main(int argc, char *argv[])
if (gethostname(hostname, sizeof hostname) == -1)
err(1, "gethostname");
- for (i = 0; i < MAXCON; i++)
- con[i].fd = -1;
-
while ((ch = getopt(argc, argv, "45c:p:dr:n:")) != -1) {
switch (ch) {
case '4':
@@ -380,6 +377,13 @@ main(int argc, char *argv[])
}
}
+ con = calloc(maxcon, sizeof(*con));
+ if (con == NULL)
+ err(1, "calloc");
+
+ for (i = 0; i < maxcon; i++)
+ con[i].fd = -1;
+
signal(SIGPIPE, SIG_IGN);
s = socket(AF_INET, SOCK_STREAM, 0);