aboutsummaryrefslogtreecommitdiff
path: root/mail/spamguard
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-09-23 14:15:14 +0000
committerStefan Eßer <se@FreeBSD.org>2020-09-23 14:15:14 +0000
commit6a919278eb06549eaa75f2c3e2e4496f00cfd96a (patch)
tree73b5f7573f07b621b06b0728352011756528fcdd /mail/spamguard
parent22ee4bce802d50841be241bfbf6e86365deb1e80 (diff)
downloadports-6a919278eb06549eaa75f2c3e2e4496f00cfd96a.tar.gz
ports-6a919278eb06549eaa75f2c3e2e4496f00cfd96a.zip
Fix build with -fno-common and correct software bugs
There were software bugs in 3 source files, most due to wrong use of sizeof (e.g. using the size of a pointer instead of the data, or subtracting a value from the argument of sizeof, not the resulting size value. A test for a short write assigned the length written to a variable and performed a comparison with that variable in a single expression and with no defined order of the these two operations resulting in either a comparison with 0 (the value before assignement) or with the just assigned value (tautological comparison). Either case did not catch a short write. I have not checked the quality of the code nay further than these issues that caused compiler warnings, but given the severity and fundamental lack of understanding shown by these examples, I'm not convinced that this program can be trusted to work correctly.
Notes
Notes: svn path=/head/; revision=549729
Diffstat (limited to 'mail/spamguard')
-rw-r--r--mail/spamguard/Makefile2
-rw-r--r--mail/spamguard/files/patch-Makefile.am6
-rw-r--r--mail/spamguard/files/patch-config.h.in19
-rw-r--r--mail/spamguard/files/patch-functions.c31
-rw-r--r--mail/spamguard/files/patch-functions.h13
-rw-r--r--mail/spamguard/files/patch-hash.c20
-rw-r--r--mail/spamguard/files/patch-hash.h20
-rw-r--r--mail/spamguard/files/patch-loadconfig.c28
-rw-r--r--mail/spamguard/files/patch-loadconfig.h42
-rw-r--r--mail/spamguard/files/patch-main.c14
-rw-r--r--mail/spamguard/files/patch-parser.c11
-rw-r--r--mail/spamguard/files/patch-qsheff__parser.c23
12 files changed, 226 insertions, 3 deletions
diff --git a/mail/spamguard/Makefile b/mail/spamguard/Makefile
index beb42cd9c1ef..e4fe5b49e7ce 100644
--- a/mail/spamguard/Makefile
+++ b/mail/spamguard/Makefile
@@ -3,6 +3,7 @@
PORTNAME= spamguard
PORTVERSION= 1.8
+PORTREVISION= 1
CATEGORIES= mail
MASTER_SITES= http://www.enderunix.org/spamguard/
@@ -10,6 +11,7 @@ MAINTAINER= bofh@FreeBSD.org
COMMENT= MTA spam prevention program for qmail/postfix/sendmail
LICENSE= BSD3CLAUSE
+LICENSE_FILE= ${WRKSRC}/COPYING
WRKSRC= ${WRKDIR}/${PORTNAME}
GNU_CONFIGURE= yes
diff --git a/mail/spamguard/files/patch-Makefile.am b/mail/spamguard/files/patch-Makefile.am
index f9efd7112dc4..ddc98cba35e5 100644
--- a/mail/spamguard/files/patch-Makefile.am
+++ b/mail/spamguard/files/patch-Makefile.am
@@ -1,5 +1,5 @@
---- Makefile.am.orig 2012-03-28 17:13:44.319243270 +0600
-+++ Makefile.am 2012-03-28 17:14:10.552245509 +0600
+--- Makefile.am.orig 2007-05-11 06:46:52 UTC
++++ Makefile.am
@@ -1,22 +1,8 @@
#EnderUNIX spamguard Makefile.am file
-SUBDIRS = tr
@@ -23,7 +23,7 @@
spamguard_confdir = ${sysconfdir}/spamguard
spamguard_conf_DATA = spam-ignore.txt\
spam-ignore.txt.sample\
-@@ -36,7 +22,7 @@
+@@ -36,7 +22,7 @@ spamguard_headers = functions.h\
qsheff_parser.h\
hash.h
diff --git a/mail/spamguard/files/patch-config.h.in b/mail/spamguard/files/patch-config.h.in
new file mode 100644
index 000000000000..12c67ae2ffcb
--- /dev/null
+++ b/mail/spamguard/files/patch-config.h.in
@@ -0,0 +1,19 @@
+--- config.h.in.orig 2007-05-08 06:59:20 UTC
++++ config.h.in
+@@ -78,6 +78,9 @@
+ /* Define to the one symbol short name of this package. */
+ #undef PACKAGE_TARNAME
+
++/* Define to the home page for this package. */
++#undef PACKAGE_URL
++
+ /* Define to the version of this package. */
+ #undef PACKAGE_VERSION
+
+@@ -90,5 +93,5 @@
+ /* Define to rpl_malloc if the replacement function should be used. */
+ #undef malloc
+
+-/* Define to `unsigned' if <sys/types.h> does not define. */
++/* Define to `unsigned int' if <sys/types.h> does not define. */
+ #undef size_t
diff --git a/mail/spamguard/files/patch-functions.c b/mail/spamguard/files/patch-functions.c
new file mode 100644
index 000000000000..fe7c4ded72bc
--- /dev/null
+++ b/mail/spamguard/files/patch-functions.c
@@ -0,0 +1,31 @@
+--- functions.c.orig 2008-01-21 15:41:05 UTC
++++ functions.c
+@@ -10,16 +10,9 @@
+ #include "wildmat.h"
+ #include "hash.h"
+
+-extern char mail_command[VALSIZE];
+-extern char makemap_command[VALSIZE];
+-extern char sysadmin[VALSIZE];
+-extern char statfile[VALSIZE];
+-extern char badmailfile[VALSIZE];
++maddr *spammer_hash[MAXADDR];
++iaddr *iaddrlist;
+
+-extern int wcnt;
+-extern int bcnt;
+-extern int pcnt;
+-
+ extern int w;
+ extern int b;
+ extern int p;
+@@ -107,7 +100,8 @@ send_notify_mail(char *n, char *sender, char *spam_typ
+ return errno;
+ }
+
+- if ((bytes = write(fd, n, strlen(n))) < bytes) {
++ bytes = strlen(n);
++ if (write(fd, n, bytes) < bytes) {
+ fprintf(stderr, "Couldn't write to temporary file");
+ return errno;
+ }
diff --git a/mail/spamguard/files/patch-functions.h b/mail/spamguard/files/patch-functions.h
new file mode 100644
index 000000000000..b95b2bf81277
--- /dev/null
+++ b/mail/spamguard/files/patch-functions.h
@@ -0,0 +1,13 @@
+--- functions.h.orig 2007-05-07 06:38:05 UTC
++++ functions.h
+@@ -28,8 +28,8 @@ struct iaddr {
+ iaddr *next;
+ };
+
+-maddr *spammer_hash[MAXADDR];
+-iaddr *iaddrlist;
++extern maddr *spammer_hash[MAXADDR];
++extern iaddr *iaddrlist;
+
+
+ int
diff --git a/mail/spamguard/files/patch-hash.c b/mail/spamguard/files/patch-hash.c
new file mode 100644
index 000000000000..c55f85f37cda
--- /dev/null
+++ b/mail/spamguard/files/patch-hash.c
@@ -0,0 +1,20 @@
+--- hash.c.orig 2007-05-10 21:18:39 UTC
++++ hash.c
+@@ -141,7 +141,7 @@ hash_lookup(const char *target, unsigned int h)
+ bp = bucket_arr[h];
+
+ while (bp != NULL) {
+- if (! strncmp(bp->subject, target, sizeof(target)))
++ if (! strncmp(bp->subject, target, sizeof(bp->subject)))
+ return bp;
+ bp = bp->next;
+ }
+@@ -156,7 +156,7 @@ hash_lookup_IP(const char *target, unsigned int h)
+ ip = IP_bucket_arr[h];
+
+ while (ip != NULL) {
+- if (! strncmp(ip->IP, target, sizeof(target)))
++ if (! strncmp(ip->IP, target, sizeof(ip->IP)))
+ return 1;
+ ip = ip->next;
+ }
diff --git a/mail/spamguard/files/patch-hash.h b/mail/spamguard/files/patch-hash.h
new file mode 100644
index 000000000000..523f91af119b
--- /dev/null
+++ b/mail/spamguard/files/patch-hash.h
@@ -0,0 +1,20 @@
+--- hash.h.orig 2007-05-10 21:18:39 UTC
++++ hash.h
+@@ -18,7 +18,7 @@ struct IP_bucket {
+ char IP[RECVFROM];
+ IP_bucket *next;
+ };
+-IP_bucket* IP_bucket_arr[NUM_HASH];
++extern IP_bucket* IP_bucket_arr[NUM_HASH];
+
+
+ typedef struct bucket bucket;
+@@ -30,7 +30,7 @@ struct bucket {
+ int is_spammer;
+ bucket *next;
+ };
+-bucket* bucket_arr[NUM_HASH];
++extern bucket* bucket_arr[NUM_HASH];
+
+ extern unsigned int
+ cdbhash(char *buf, unsigned int len);
diff --git a/mail/spamguard/files/patch-loadconfig.c b/mail/spamguard/files/patch-loadconfig.c
new file mode 100644
index 000000000000..50e702b5ca78
--- /dev/null
+++ b/mail/spamguard/files/patch-loadconfig.c
@@ -0,0 +1,28 @@
+--- loadconfig.c.orig 2007-05-14 15:19:00 UTC
++++ loadconfig.c
+@@ -10,6 +10,25 @@
+
+ #include "loadconfig.h"
+
++
++int wcnt;
++int bcnt;
++int pcnt;
++int enable_subj_filt;
++
++char logtype[VALSIZE];
++char logfile[VALSIZE];
++char ignorefile[VALSIZE];
++char highfile[VALSIZE];
++char badmailfile[VALSIZE];
++char hostname[VALSIZE];
++char sysadmin[VALSIZE];
++char statfile[VALSIZE];
++char mail_command[VALSIZE];
++char makemap_command[VALSIZE];
++char qsheff_rules_file[VALSIZE];
++char trim_subj_str[VALSIZE];
++
+ extern int errno;
+ extern int w;
+ extern int b;
diff --git a/mail/spamguard/files/patch-loadconfig.h b/mail/spamguard/files/patch-loadconfig.h
new file mode 100644
index 000000000000..e298891d7358
--- /dev/null
+++ b/mail/spamguard/files/patch-loadconfig.h
@@ -0,0 +1,42 @@
+--- loadconfig.h.orig 2007-05-14 15:19:00 UTC
++++ loadconfig.h
+@@ -12,23 +12,23 @@ enum {
+ VALSIZE = 256
+ };
+
+-int wcnt;
+-int bcnt;
+-int pcnt;
+-int enable_subj_filt;
++extern int wcnt;
++extern int bcnt;
++extern int pcnt;
++extern int enable_subj_filt;
+
+-char logtype[VALSIZE];
+-char logfile[VALSIZE];
+-char ignorefile[VALSIZE];
+-char highfile[VALSIZE];
+-char badmailfile[VALSIZE];
+-char hostname[VALSIZE];
+-char sysadmin[VALSIZE];
+-char statfile[VALSIZE];
+-char mail_command[VALSIZE];
+-char makemap_command[VALSIZE];
+-char qsheff_rules_file[VALSIZE];
+-char trim_subj_str[VALSIZE];
++extern char logtype[VALSIZE];
++extern char logfile[VALSIZE];
++extern char ignorefile[VALSIZE];
++extern char highfile[VALSIZE];
++extern char badmailfile[VALSIZE];
++extern char hostname[VALSIZE];
++extern char sysadmin[VALSIZE];
++extern char statfile[VALSIZE];
++extern char mail_command[VALSIZE];
++extern char makemap_command[VALSIZE];
++extern char qsheff_rules_file[VALSIZE];
++extern char trim_subj_str[VALSIZE];
+
+ void
+ loadconfig(const char *);
diff --git a/mail/spamguard/files/patch-main.c b/mail/spamguard/files/patch-main.c
new file mode 100644
index 000000000000..90bbfa5e2f49
--- /dev/null
+++ b/mail/spamguard/files/patch-main.c
@@ -0,0 +1,14 @@
+--- main.c.orig 2007-05-07 06:38:05 UTC
++++ main.c
+@@ -27,11 +27,6 @@
+ #include "qsheff_parser.h"
+ #include "config.h"
+
+-extern char logtype[VALSIZE];
+-extern char logfile[VALSIZE];
+-extern char ignorefile[VALSIZE];
+-extern char badmailfile[VALSIZE];
+-
+ int w = 0;
+ int b = 0;
+ int p = 0;
diff --git a/mail/spamguard/files/patch-parser.c b/mail/spamguard/files/patch-parser.c
new file mode 100644
index 000000000000..0aa20e32ad59
--- /dev/null
+++ b/mail/spamguard/files/patch-parser.c
@@ -0,0 +1,11 @@
+--- parser.c.orig 2007-05-04 06:37:36 UTC
++++ parser.c
+@@ -14,8 +14,6 @@
+ #include "loadconfig.h"
+ #include "parser.h"
+
+-extern char logtype[VALSIZE];
+-
+ void
+ read_logfile(char *fn)
+ {
diff --git a/mail/spamguard/files/patch-qsheff__parser.c b/mail/spamguard/files/patch-qsheff__parser.c
new file mode 100644
index 000000000000..87688fd8725f
--- /dev/null
+++ b/mail/spamguard/files/patch-qsheff__parser.c
@@ -0,0 +1,23 @@
+--- qsheff_parser.c.orig 2007-05-30 14:06:19 UTC
++++ qsheff_parser.c
+@@ -1,6 +1,9 @@
+ #include <stdio.h>
+ #include "qsheff_parser.h"
+
++IP_bucket* IP_bucket_arr[NUM_HASH];
++bucket* bucket_arr[NUM_HASH];
++
+ extern int w;
+ extern int b;
+ extern int p;
+@@ -225,8 +228,8 @@ qsheff_finalize(void)
+ fprintf(fp, "%s\n", bp->recvfrom);
+ bp->is_spammer = 1;
+ printf("Paranoid Spammer: %s - %s sent %d mails\n", bp->mail, bp->recvfrom, bp->count);
+- snprintf(mailbuf, sizeof(mailbuf - 1), " %s - %s has been spamming your box! (sent %d mails)\n No matter this mail address is matched against your spam high list: %s, or not. I'm still adding it to blacklist since s/he sent more mails then your paranoid threshold.\n\n Source mail address has been added to %s file\n Target successfully nuked!\n\n Regards,\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", bp->mail, bp->recvfrom, bp->count, highfile, badmailfile, VERSION);
+- mailbuf[sizeof(mailbuf - 2)] = '\0'; /* -1 is for NULL byte, the other -1 is for 'Sir BALABAN Byte' ... */
++ snprintf(mailbuf, sizeof(mailbuf) - 1, " %s - %s has been spamming your box! (sent %d mails)\n No matter this mail address is matched against your spam high list: %s, or not. I'm still adding it to blacklist since s/he sent more mails then your paranoid threshold.\n\n Source mail address has been added to %s file\n Target successfully nuked!\n\n Regards,\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", bp->mail, bp->recvfrom, bp->count, highfile, badmailfile, VERSION);
++ mailbuf[sizeof(mailbuf) - 2] = '\0'; /* -1 is for NULL byte, the other -1 is for 'Sir BALABAN Byte' ... */
+ send_notify_mail(mailbuf, bp->recvfrom, "paranoid ");
+ }
+