6a919278eb
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.
32 lines
798 B
C
32 lines
798 B
C
--- 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;
|
|
}
|