diff -Nru ssmtp-2.64/debian/changelog ssmtp-2.64/debian/changelog --- ssmtp-2.64/debian/changelog 2014-04-11 17:44:25.000000000 +0000 +++ ssmtp-2.64/debian/changelog 2014-07-15 00:49:35.000000000 +0000 @@ -1,3 +1,15 @@ +ssmtp (2.64-8) unstable; urgency=medium + + * Fix "Partial loss of message body, sending message to wrong recipicients". + Reported by Christoph Biedl . + Patch by "Daniel Richard G." . + Add ssmtp-bug584162-fix.patch. + Closes: #584162. + * Refresh patches. + * Standards-Version: 3.9.5. + + -- Anibal Monsalve Salazar Tue, 15 Jul 2014 01:49:18 +0100 + ssmtp (2.64-7.1) unstable; urgency=medium * Non-maintainer upload. diff -Nru ssmtp-2.64/debian/control ssmtp-2.64/debian/control --- ssmtp-2.64/debian/control 2014-04-06 13:53:14.000000000 +0000 +++ ssmtp-2.64/debian/control 2014-07-15 00:34:15.000000000 +0000 @@ -3,7 +3,7 @@ Priority: extra Maintainer: Anibal Monsalve Salazar Build-Depends: dpkg-dev (>= 1.16.1~), po-debconf, libgnutls-openssl-dev -Standards-Version: 3.9.3 +Standards-Version: 3.9.5 Vcs-Git: git://git.debian.org/ssmtp/ssmtp.git Vcs-Browser: http://git.debian.org/?p=ssmtp/ssmtp.git Homepage: http://packages.qa.debian.org/s/ssmtp.html diff -Nru ssmtp-2.64/debian/patches/01-374327-use-gnutls.patch ssmtp-2.64/debian/patches/01-374327-use-gnutls.patch --- ssmtp-2.64/debian/patches/01-374327-use-gnutls.patch 2011-08-11 11:14:32.000000000 +0000 +++ ssmtp-2.64/debian/patches/01-374327-use-gnutls.patch 2014-07-15 00:43:51.000000000 +0000 @@ -14,8 +14,10 @@ Alejandro Rios Anibal Monsalve Salazar ---- a/configure 2008-03-07 07:53:03.000000000 +1100 -+++ b/configure 2009-07-06 23:33:59.000000000 +1000 +Index: ssmtp-2.64/configure +=================================================================== +--- ssmtp-2.64.orig/configure ++++ ssmtp-2.64/configure @@ -1562,7 +1562,7 @@ if test x$enableval = xyes ; then #define HAVE_SSL 1 EOF @@ -25,8 +27,10 @@ fi enableval="" ---- a/configure.in 2008-03-07 06:34:46.000000000 +1100 -+++ b/configure.in 2009-07-06 23:33:59.000000000 +1000 +Index: ssmtp-2.64/configure.in +=================================================================== +--- ssmtp-2.64.orig/configure.in ++++ ssmtp-2.64/configure.in @@ -52,7 +52,7 @@ AC_ARG_ENABLE(ssl, [ --enable-ssl support for secure connection to mail server]) if test x$enableval = xyes ; then @@ -36,8 +40,10 @@ fi enableval="" ---- a/ssmtp.c 2009-07-06 22:48:57.000000000 +1000 -+++ b/ssmtp.c 2009-07-06 23:33:59.000000000 +1000 +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c @@ -26,11 +26,7 @@ #include #include diff -Nru ssmtp-2.64/debian/patches/02-557725-solaris.patch ssmtp-2.64/debian/patches/02-557725-solaris.patch --- ssmtp-2.64/debian/patches/02-557725-solaris.patch 2009-11-24 00:12:41.000000000 +0000 +++ ssmtp-2.64/debian/patches/02-557725-solaris.patch 2014-07-15 00:44:38.000000000 +0000 @@ -2,8 +2,10 @@ Patch by Darik Horn ---- a/generate_config 2004-07-23 15:58:48.000000000 +1000 -+++ b/generate_config 2009-11-24 11:02:02.000000000 +1100 +Index: ssmtp-2.64/generate_config +=================================================================== +--- ssmtp-2.64.orig/generate_config ++++ ssmtp-2.64/generate_config @@ -1,10 +1,16 @@ -#!/bin/sh -e +#!/bin/bash -e @@ -23,9 +25,11 @@ if test -f /etc/mailname then mailname="`head -1 /etc/mailname`" ---- a/ssmtp.c 2009-11-23 20:55:11.000000000 +1100 -+++ b/ssmtp.c 2009-11-24 11:02:02.000000000 +1100 -@@ -97,6 +93,20 @@ static char hextab[]="0123456789abcdef"; +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -93,6 +93,20 @@ static char hextab[]="0123456789abcdef"; ssize_t outbytes; diff -Nru ssmtp-2.64/debian/patches/03-557741-remote-addr.patch ssmtp-2.64/debian/patches/03-557741-remote-addr.patch --- ssmtp-2.64/debian/patches/03-557741-remote-addr.patch 2009-11-24 02:32:16.000000000 +0000 +++ ssmtp-2.64/debian/patches/03-557741-remote-addr.patch 2014-07-15 00:45:18.000000000 +0000 @@ -3,9 +3,11 @@ Patch by Victor Sudakov Modified by Anibal Monsalve Salazar ---- a/ssmtp.c 2009-11-23 20:55:11.000000000 +1100 -+++ b/ssmtp.c 2009-11-24 13:27:58.000000000 +1100 -@@ -1409,6 +1409,7 @@ +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -1421,6 +1421,7 @@ ssmtp() -- send the message (exactly one int ssmtp(char *argv[]) { char b[(BUF_SZ + 2)], *buf = b+1, *p, *q; @@ -13,7 +15,7 @@ #ifdef MD5AUTH char challenge[(BUF_SZ + 1)]; #endif -@@ -1612,6 +1613,10 @@ +@@ -1624,6 +1625,10 @@ int ssmtp(char *argv[]) outbytes += smtp_write(sock, "From: %s", from); } diff -Nru ssmtp-2.64/debian/patches/04-508759-garbage.patch ssmtp-2.64/debian/patches/04-508759-garbage.patch --- ssmtp-2.64/debian/patches/04-508759-garbage.patch 2012-06-24 23:57:25.000000000 +0000 +++ ssmtp-2.64/debian/patches/04-508759-garbage.patch 2014-07-15 00:46:38.000000000 +0000 @@ -1,10 +1,11 @@ Common subdirectories: ssmtp-original/debian and ssmtp-2.62/debian Common subdirectories: ssmtp-original/md5auth and ssmtp-2.62/md5auth Common subdirectories: ssmtp-original/.pc and ssmtp-2.62/.pc -diff -u ssmtp-original/ssmtp.c ssmtp-2.62/ssmtp.c ---- ssmtp-original/ssmtp.c 2009-11-29 13:47:29.000000000 -0500 -+++ ssmtp-2.62/ssmtp.c 2009-11-29 13:51:18.000000000 -0500 -@@ -1649,12 +1649,12 @@ +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -1674,12 +1674,12 @@ int ssmtp(char *argv[]) outbytes += smtp_write(sock, "%s", leadingdot ? b : buf); } else { if (log_level > 0) { diff -Nru ssmtp-2.64/debian/patches/05-LDFLAGS.patch ssmtp-2.64/debian/patches/05-LDFLAGS.patch --- ssmtp-2.64/debian/patches/05-LDFLAGS.patch 2012-06-29 22:59:23.000000000 +0000 +++ ssmtp-2.64/debian/patches/05-LDFLAGS.patch 2014-07-15 00:47:27.000000000 +0000 @@ -1,5 +1,7 @@ ---- a/Makefile.in 2008-02-29 13:50:15.000000000 +1100 -+++ b/Makefile.in 2012-06-30 08:56:17.337703517 +1000 +Index: ssmtp-2.64/Makefile.in +=================================================================== +--- ssmtp-2.64.orig/Makefile.in ++++ ssmtp-2.64/Makefile.in @@ -79,7 +79,7 @@ uninstall-sendmail: uninstall # Binaries: diff -Nru ssmtp-2.64/debian/patches/debian-changes-2.64-1 ssmtp-2.64/debian/patches/debian-changes-2.64-1 --- ssmtp-2.64/debian/patches/debian-changes-2.64-1 2009-11-24 03:33:25.000000000 +0000 +++ ssmtp-2.64/debian/patches/debian-changes-2.64-1 2014-07-15 00:46:03.000000000 +0000 @@ -35,9 +35,11 @@ Reviewed-By: Last-Update: +Index: ssmtp-2.64/ssmtp.conf.5 +=================================================================== --- ssmtp-2.64.orig/ssmtp.conf.5 +++ ssmtp-2.64/ssmtp.conf.5 -@@ -26,7 +26,7 @@ The user that gets all mail for userids +@@ -26,7 +26,7 @@ The user that gets all mail for userids .Pp .It Cm Mailhub The host to send mail to, in the form diff -Nru ssmtp-2.64/debian/patches/series ssmtp-2.64/debian/patches/series --- ssmtp-2.64/debian/patches/series 2012-06-29 22:57:47.000000000 +0000 +++ ssmtp-2.64/debian/patches/series 2014-07-15 00:24:45.000000000 +0000 @@ -4,3 +4,4 @@ debian-changes-2.64-1 04-508759-garbage.patch 05-LDFLAGS.patch +ssmtp-bug584162-fix.patch diff -Nru ssmtp-2.64/debian/patches/ssmtp-bug584162-fix.patch ssmtp-2.64/debian/patches/ssmtp-bug584162-fix.patch --- ssmtp-2.64/debian/patches/ssmtp-bug584162-fix.patch 1970-01-01 00:00:00.000000000 +0000 +++ ssmtp-2.64/debian/patches/ssmtp-bug584162-fix.patch 2014-07-15 00:27:17.000000000 +0000 @@ -0,0 +1,120 @@ +Bug-Debian: http://bugs.debian.org/584162 +Reported-By: Christoph Biedl +Forwarded: not-needed +Reviewed-By: Anibal Monsalve Salazar +Last-Update: 2014-08-15 + +From: "Daniel Richard G." +Subject: Re: ssmtp: Partial loss of message body, sending message to wrong recipicients +Date: Thu, 19 Jun 2014 14:44:30 -0400 + +Attached is a patch against the original 2.64 source that should address +this bug, and hopefully not break anything. An overview of my changes: + +* Added code to standarise() to drop the trailing '\r' if the line + originally ended with "\r\n". + +* Added a check to header_parse() that effectively converts an "\r\n" in + the input into '\n'. + +* Added a conditional so that header_parse() doesn't pass the empty + string to header_save()---a behavior I observed in testing, at the end + of a header block with "\r\n" line endings. + +* Simplified the last if(in_header) conditional in header_parse(), + because it erroneously assumes that if in_header == True, then c could + have some value other than EOF. (See the condition on the previous + "while" loop, and the lack of any other way to exit said loop.) + + header_parse() will now properly grab a header if fed a message + without a body (i.e. no "\n\n" ending the header block), although this + code will still drop a header if there is no newline at the end. + +Christoph, thank you for your excellent analysis, and the test cases. I +made use of them, and with my changes sSMTP appears to do the right +thing. + +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -375,6 +375,12 @@ bool_t standardise(char *str, bool_t *li + if((p = strchr(str, '\n'))) { + *p = (char)NULL; + *linestart = True; ++ ++ /* If the line ended in "\r\n", then drop the '\r' too */ ++ sl = strlen(str); ++ if(sl >= 1 && str[sl - 1] == '\r') { ++ str[sl - 1] = (char)NULL; ++ } + } + return(leadingdot); + } +@@ -768,6 +774,14 @@ void header_parse(FILE *stream) + } + len++; + ++ if(l == '\r' && c == '\n') { ++ /* Properly handle input that already has "\r\n" ++ line endings; see https://bugs.debian.org/584162 */ ++ l = (len >= 2 ? *(q - 2) : '\n'); ++ q--; ++ len--; ++ } ++ + if(l == '\n') { + switch(c) { + case ' ': +@@ -790,7 +804,9 @@ void header_parse(FILE *stream) + if((q = strrchr(p, '\n'))) { + *q = (char)NULL; + } +- header_save(p); ++ if(len > 0) { ++ header_save(p); ++ } + + q = p; + len = 0; +@@ -800,35 +816,12 @@ void header_parse(FILE *stream) + + l = c; + } +- if(in_header) { +- if(l == '\n') { +- switch(c) { +- case ' ': +- case '\t': +- /* Must insert '\r' before '\n's embedded in header +- fields otherwise qmail won't accept our mail +- because a bare '\n' violates some RFC */ +- +- *(q - 1) = '\r'; /* Replace previous \n with \r */ +- *q++ = '\n'; /* Insert \n */ +- len++; +- +- break; +- +- case '\n': +- in_header = False; +- +- default: +- *q = (char)NULL; +- if((q = strrchr(p, '\n'))) { +- *q = (char)NULL; +- } +- header_save(p); +- +- q = p; +- len = 0; +- } ++ if(in_header && l == '\n') { ++ /* Got EOF while reading the header */ ++ if((q = strrchr(p, '\n'))) { ++ *q = (char)NULL; + } ++ header_save(p); + } + (void)free(p); + }