report a bug |  advanced search |  statistics |  developer log in/out

Patch Reduce-subscription-confirmation-address-length for Generic Bug #63

Patch version 2017-05-25 12:30 UTC

Return to Bug #63 | Download this patch
Patch Revisions:

Developer: stappers@stappers.it

From cb0788bc35c471a87fc75aca6d4e405fdbaccfd8 Mon Sep 17 00:00:00 2001
From: Geert Stappers <stappers@stappers.it>
Date: Thu, 25 May 2017 09:17:55 +0200
Subject: [PATCH] Reduce subscription confirmation address length to fit RFC
 5321

The local part of mailing list subscription confirmation addresses
formed of:

  mailing-list-name "+confsub-" 16-random-hex "-" sender-address

can get very long, especially if sender-address is long.
However, RFC limits it at 64 characters.

Closes http://mlmmj.org/bugs/bug.php?id=63

Reported-by: mgorny@gentoo.org
---
 src/mlmmj-sub.c   |  2 +-
 src/mlmmj-unsub.c |  2 +-
 src/strgen.c      | 23 +----------------------
 3 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/src/mlmmj-sub.c b/src/mlmmj-sub.c
index 3335817..5c8c1ae 100644
--- a/src/mlmmj-sub.c
+++ b/src/mlmmj-sub.c
@@ -413,7 +413,7 @@ void generate_subconfirm(const char *listdir, const char *listaddr,
         do {
                 myfree(confirmfilename);
                 myfree(randomstr);
-		randomstr = random_plus_addr(subaddr);
+		randomstr = random_str();
                 confirmfilename = concatstr(3, listdir, "/subconf/",
 					    randomstr);
 
diff --git a/src/mlmmj-unsub.c b/src/mlmmj-unsub.c
index 0fa42a1..8e13f3c 100644
--- a/src/mlmmj-unsub.c
+++ b/src/mlmmj-unsub.c
@@ -171,7 +171,7 @@ void generate_unsubconfirm(const char *listdir, const char *listaddr,
         do {
                 myfree(confirmfilename);
                 myfree(randomstr);
-		randomstr = random_plus_addr(subaddr);
+		randomstr = random_str();
                 confirmfilename = concatstr(3, listdir, "/unsubconf/",
 					    randomstr);
 
diff --git a/src/strgen.c b/src/strgen.c
index f13db47..673f44a 100644
--- a/src/strgen.c
+++ b/src/strgen.c
@@ -40,31 +40,10 @@
 
 char *random_str()
 {
-	size_t len = 17;
+	size_t len = 17; /* sixteen hex digits plus terminating zero */
 	char *dest = mymalloc(len);
 
 	snprintf(dest, len, "%08x%08x", random_int(), random_int());
-
-	return dest;
-}
-
-char *random_plus_addr(const char *addr)
-{
-	size_t len = strlen(addr) + 128;
-	char *dest = mymalloc(len);
-	char *atsign;
-	char *tmpstr;
-
-	tmpstr = mymalloc(len);
-	snprintf(tmpstr, len, "%s", addr);
-
-	atsign = strchr(tmpstr, '@');
-	MY_ASSERT(atsign);
-	*atsign = '=';
-
-	snprintf(dest, len, "%08x%08x-%s", random_int(), random_int(), tmpstr);
-
-	myfree(tmpstr);
 	
 	return dest;
 }
-- 
2.11.0

 
Based on the PHP bug tracker.
Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jan 30 01:27:44 2013 UTC