[exim-cvs] Fix encoding for AUTH= on MAIL FROM

Inizio della pagina
Delete this message
Reply to this message
Autore: Exim Git Commits Mailing List
Data:  
To: exim-cvs
Oggetto: [exim-cvs] Fix encoding for AUTH= on MAIL FROM
Gitweb: https://git.exim.org/exim.git/commitdiff/4e19eed51a7f777e1e18b60c636e0c9bfb82c23b
Commit:     4e19eed51a7f777e1e18b60c636e0c9bfb82c23b
Parent:     f168d6a2c93ee92d87744ce09c45a0ec666f889c
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Wed Mar 27 16:04:50 2024 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Wed Mar 27 16:04:50 2024 +0000


    Fix encoding for AUTH= on MAIL FROM
---
 doc/doc-txt/ChangeLog       |  4 ++++
 src/src/auths/xtextencode.c | 33 ++++++++-------------------------
 2 files changed, 12 insertions(+), 25 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index a6da95001..77322c73f 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -128,6 +128,10 @@ JH/24 Bug 3081: Fix a delivery process crash.  When the router "errors_to"
 JH/25 Bug 3079: Fix crash in dbmnz.  When a key was present for zero-length
       data a null pointer was followed.  Find and testcase by Sebastian Bugge.


+JH/26 Fix encoding for an AUTH parameter on a MAIL FROM command.  Previously
+      decimal 127 chars were not encoded, and lowercase hex was used for
+      encoded values.  Outstanding since at least 1999.
+


 Exim version 4.97
 -----------------
diff --git a/src/src/auths/xtextencode.c b/src/src/auths/xtextencode.c
index c08288831..75be18161 100644
--- a/src/src/auths/xtextencode.c
+++ b/src/src/auths/xtextencode.c
@@ -29,31 +29,14 @@ Returns:      a pointer to the zero-terminated xtext string, which
 uschar *
 auth_xtextencode(uschar *clear, int len)
 {
-uschar *code;
-uschar *p = US clear;
-uschar *pp;
-int c = len;
-int count = 1;
-register int x;
-
-/* We have to do a prepass to find out how many specials there are,
-in order to get the right amount of store. */
-
-while (c -- > 0)
-  count += ((x = *p++) < 33 || x > 127 || x == '+' || x == '=')? 3 : 1;
-
-pp = code = store_get(count, clear);
-
-p = US clear;
-c = len;
-while (c-- > 0)
-  if ((x = *p++) < 33 || x > 127 || x == '+' || x == '=')
-    pp += sprintf(CS pp, "+%.02x", x);   /* There's always room */
-  else
-    *pp++ = x;
-
-*pp = 0;
-return code;
+gstring * g = NULL;
+for(uschar ch; len > 0; len--, clear++)
+  g = (ch = *clear) < 33 || ch > 126 || ch == '+' || ch == '='
+    ? string_fmt_append(g, "+%.02X", ch)
+    : string_catn(g, clear, 1);
+gstring_release_unused(g);
+return string_from_gstring(g);
 }


+
/* End of xtextencode.c */

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/