Words by Robert Müller [Mon, Mar 16, 2009 at 09:24:55PM +0100]:
> Hi,
>
> Be careful: Continuation of an older post ;-):
> I just took a look at your howto's and software (great work, really!) and 
> decided to give greetdelay and policyd-integration a try. Unfortunately, 
> the qenvscan-policyd binary doesn't run on a amd64 kernel. It compiles 
> fine, but running it results in a segfault. I'm using Debian 5.0.
> On a Debian 4.0 x686 it runs fine.
> As I'm not a developer - can you please help?
>

Try the attached patch (couldn't try it as I don't have a policy server
and whatever needed).

-- 
Jose Celestino | http://japc.uncovering.org/files/japc-pgpkey.asc
----------------------------------------------------------------
"One man’s theology is another man’s belly laugh." -- Robert A. Heinlein
--- qenvscan-policyd/qenvscan-policyd.c	2009-03-16 21:24:59.000000000 +0000
+++ qenvscan-policyd-japc/qenvscan-policyd.c	2009-03-16 21:24:07.000000000 +0000
@@ -65,6 +65,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
+#include <limits.h>
 
 
 #define SIZEOF_INT		sizeof(int)
@@ -88,8 +89,8 @@
     char answer[32];
 	char *policyd_server, *policyd_env_port, *end_ptr;
 
-	char *key[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-	char *value[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+	char *key[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+	char *value[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 	char *query;
 	
 	int keylens[8];
@@ -121,7 +122,7 @@
 	key[4] = "client_name=";
 	key[5] = "sender=";
 	key[6] = "recipient=";
-	key[7] = argv[3] != NULL ? "helo_name=" : 0;
+	key[7] = argv[3] != NULL ? "helo_name=" : NULL;
 
 	value[0] = "smtpd_access_policy";
 	value[1] = "SMTP";
@@ -132,33 +133,27 @@
 	value[6] = argv[2];
 	value[7] = argv[3] != NULL ? argv[3] : 0;
 
-	for (i=0;i<sizeof(key)/SIZEOF_INT;i++) {
-		if (key[i] != NULL) {
+	for (i=0; key[i]; i++) {
 			keylens[i] = strlen(key[i]);
 			keylen += keylens[i];
 		}
-	}
 
-	for (i=0;i<sizeof(value)/SIZEOF_INT;i++) {
-		if (value[i] != NULL) {
+	for (i=0; value[i]; i++) {
 			valuelens[i] = strlen(value[i]);
 			valuelen += valuelens[i];
 		}
-	}
 
 	len = keylen + valuelen + sizeof(key)/SIZEOF_INT + 2;
 
 	query = malloc(len);
 
-	for (i=j=0;i<sizeof(key)/SIZEOF_INT && j<len;i++) {
-		if (key[i] != NULL && value[i] != NULL) {
+	for (i=j=0; key[i] && value[i] && j<len;i++) {
 			strcpy(query+j, key[i]);
 			j += keylens[i];
 			strcpy(query+j, value[i]);
 			j += valuelens[i];
 			query[j++] = '\n';
 		}
-	}
 	query[j++] = '\n';
 	query[j++] = '\0';
 	

Reply via email to