I use AS IS now to be sure...

I also rewrote my RFC2554 patch to make it easier to administer the
xtext-functions for the future.

Bis denne,
        Aiko
-- 
  .~.    Aiko Barz
  /v\    
 // \\   Mail: [EMAIL PROTECTED]
/( _ )\  Web:  http://www.chroot.de
 ^^ ^^   PGP:  http://www.chroot.de/index.php?navi=GnuPG

diff -ruN qmail-1.03.orig/Makefile qmail-1.03/Makefile
--- qmail-1.03.orig/Makefile    2004-08-18 16:36:46.145923320 +0200
+++ qmail-1.03/Makefile 2004-08-18 16:41:46.332288056 +0200
@@ -1930,12 +1930,13 @@
 load qmail-remote.o control.o constmap.o timeoutread.o timeoutwrite.o \
 timeoutconn.o tcpto.o now.o dns.o ip.o ipalloc.o ipme.o quote.o base64.o \
 ndelay.a case.a sig.a open.a lock.a seek.a getln.a stralloc.a alloc.a \
-strerr.a substdio.a error.a str.a fs.a auto_qmail.o dns.lib socket.lib
+strerr.a substdio.a error.a str.a fs.a auto_qmail.o dns.lib socket.lib \
+xtext.o
        ./load qmail-remote control.o constmap.o timeoutread.o \
        timeoutwrite.o timeoutconn.o tcpto.o now.o dns.o ip.o \
        ipalloc.o ipme.o quote.o base64.o ndelay.a case.a sig.a \
        open.a lock.a seek.a getln.a stralloc.a alloc.a strerr.a \
-       substdio.a error.a str.a fs.a auto_qmail.o \
+       substdio.a error.a str.a fs.a auto_qmail.o xtext.o \
        `cat dns.lib` `cat socket.lib` $(TLSLIBS) $(ZLIB)
 
 qmail-remote.0: \
@@ -1947,7 +1948,7 @@
 subfd.h substdio.h scan.h case.h error.h auto_qmail.h control.h dns.h \
 alloc.h quote.h ip.h ipalloc.h ip.h gen_alloc.h ipme.h ip.h ipalloc.h \
 gen_alloc.h gen_allocdefs.h str.h now.h datetime.h exit.h constmap.h \
-tcpto.h readwrite.h timeoutconn.h timeoutread.h timeoutwrite.h
+tcpto.h readwrite.h timeoutconn.h timeoutread.h timeoutwrite.h xtext.h
        ./compile $(LDAPFLAGS) $(TLS) $(TLSINCLUDES) $(ZINCLUDES) \
        qmail-remote.c
 
@@ -2722,6 +2723,10 @@
 compile wait_pid.c error.h haswaitp.h
        ./compile wait_pid.c
 
+xtext.o: \
+compile xtext.h
+       ./compile xtext.c
+
 cert:
        $(OPENSSLBIN) req -new -x509 -nodes \
        -out `head -n 1 conf-qmail`/control/cert.pem -days 366 \
diff -ruN qmail-1.03.orig/qmail-remote.c qmail-1.03/qmail-remote.c
--- qmail-1.03.orig/qmail-remote.c      2004-08-18 16:36:46.145923320 +0200
+++ qmail-1.03/qmail-remote.c   2004-08-18 17:52:15.884298416 +0200
@@ -33,6 +33,7 @@
 #include "timeoutread.h"
 #include "timeoutwrite.h"
 #include "base64.h"
+#include "xtext.h"
 #ifdef TLS_REMOTE /* openssl/ssh.h needs to be included befor zlib.h else ... */
 #include <sys/stat.h>
 #include <openssl/ssl.h>
@@ -458,6 +459,8 @@
 
   flagtls = 0;
 #endif
+  unsigned long xtextlen;
+  char *xtext;
 
   code = smtpcode();
   if (code >= 500) quit("DConnected to "," but greeting failed");
@@ -638,9 +641,11 @@
     substdio_put(&smtpto,num,fmt_ulong(num,len+1));
   }
   if (flagauth) {
+    xtext    = xtext_malloc(sender.s,sender.len);
     substdio_puts(&smtpto, " AUTH=<");
-    substdio_put(&smtpto,sender.s,sender.len);
+    substdio_put(&smtpto,xtext_encode(xtext,sender.s,sender.len),sender.len);
     substdio_puts(&smtpto,">");
+    xtext_free(xtext);
   }
   substdio_puts(&smtpto,"\r\n");
   substdio_flush(&smtpto);
diff -ruN qmail-1.03.orig/xtext.c qmail-1.03/xtext.c
--- qmail-1.03.orig/xtext.c     1970-01-01 01:00:00.000000000 +0100
+++ qmail-1.03/xtext.c  2004-08-18 18:41:18.274987040 +0200
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2004 Aiko Barz, [EMAIL PROTECTED]
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <stdio.h>
+
+char *xtext_malloc(char *auth_plain, unsigned long counter)
+{
+    char *plain             = auth_plain;
+    char *xtext_code        = NULL;
+    unsigned long xtext_len = 0;
+    int x;
+
+    while (counter-- > 0)
+    {
+        xtext_len += ((x = *plain++) < 33 || x > 127 || x == '+' || x == '=') ? 3 : 1;
+    }
+
+    xtext_code = (char *) malloc(xtext_len * sizeof(char));
+    
+    return(xtext_code);
+}
+
+
+char *xtext_encode(char *xtext_code, char *auth_plain, unsigned long counter)
+{
+    char *plain             = auth_plain;
+    char *p;
+    int x;
+
+    if (xtext_code == NULL)
+    {
+        return(NULL);
+    }
+
+    /*******
+     *
+     * RFC 2554:
+     * MAIL FROM:<[EMAIL PROTECTED]> AUTH=<[EMAIL PROTECTED]>
+     *
+     */
+    p = xtext_code;
+    while (counter-- > 0)
+    {   
+        if ((x = *plain++) < 33 || x > 127 || x == '+' || x == '=')
+        {   
+            sprintf(p, "+%.02x", x);
+            p += 3;
+        }
+        else
+        {
+            *p++ = x;
+        }
+    }
+
+    return(xtext_code);
+}
+
+
+void xtext_free(char *xtext_code)
+{
+    free(xtext_code);
+}
diff -ruN qmail-1.03.orig/xtext.h qmail-1.03/xtext.h
--- qmail-1.03.orig/xtext.h     1970-01-01 01:00:00.000000000 +0100
+++ qmail-1.03/xtext.h  2004-08-18 17:52:08.874364088 +0200
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2004 Aiko Barz, [EMAIL PROTECTED]
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+char *xtext_malloc(char *auth_plain, unsigned long counter);
+char *xtext_encode(char *xtext_code, char *auth_plain, unsigned long auth_length);
+void xtext_free(char *xtext_code);

Attachment: pgpRU3MZveXPh.pgp
Description: PGP signature

Reply via email to