changeset 55:bf3ca0ce00ff

fixed subscription check (convert '=' to '@' before check)
author mortenp
date Wed, 28 Apr 2004 02:07:42 +1000
parents 6e530dd3dd89
children 43d088987482
files src/mlmmj-bounce.c
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/mlmmj-bounce.c	Wed Apr 28 01:50:17 2004 +1000
+++ b/src/mlmmj-bounce.c	Wed Apr 28 02:07:42 2004 +1000
@@ -34,7 +34,7 @@
 {
 	int opt, noprocess = 0;
 	char *listdir = NULL, *address = NULL, *number = NULL;
-	char *filename, *a, *buf;
+	char *filename, *bfilename, *a, *buf;
 	size_t len;
 	int fd;
 	time_t t;
@@ -72,7 +72,14 @@
 
 	log_error(LOG_ARGS, "[%s] [%s] [%s]", listdir, address, number);
 	
-	/* First make sure it's a subscribed address */
+	/* save the filename with '=' before replacing it with '@' */
+	bfilename = concatstr(3, listdir, "/bounce/", address);
+
+	a = strchr(address, '=');
+	if (!a) exit(EXIT_SUCCESS);  /* ignore malformed address */
+	*a = '@';
+
+	/* make sure it's a subscribed address */
 	filename = concatstr(2, listdir, "/subscribers");
 	if ((fd = open(filename, O_RDONLY)) < 0) {
 		log_error(LOG_ARGS, "Could not open '%s'", filename);
@@ -83,19 +90,14 @@
 		exit(EXIT_SUCCESS); /* Not subbed, so exit silently */
 	free(filename);
 
-	filename = concatstr(3, listdir, "/bounce/", address);
 
 	/* TODO make sure the file we open below is not a symlink */
-	if ((fd = open(filename, O_WRONLY|O_APPEND|O_CREAT,
+	if ((fd = open(bfilename, O_WRONLY|O_APPEND|O_CREAT,
 			S_IRUSR|S_IWUSR)) < 0) {
-		log_error(LOG_ARGS, "Could not open '%s'", filename);
+		log_error(LOG_ARGS, "Could not open '%s'", bfilename);
 		exit(EXIT_FAILURE);
 	}
-
-	a = strchr(address, '=');
-	/* ignore malformed address */
-	if (!a) exit(EXIT_FAILURE);
-	*a = '@';
+	free(bfilename);
 
 	/* TODO check that the message is not already bounced */