ports/mail/spamguard/files/patch-qsheff__parser.c
Stefan Eßer 6a919278eb 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.
2020-09-23 14:15:14 +00:00

23 lines
1.8 KiB
C

--- 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 ");
}