#! /bin/sh /usr/share/dpatch/dpatch-run ## 0015_saslutil_decode64_fix.dpatch by ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: decode64 does not cover all cases that can arise in practise. ## DP: This patch fixes the case where no padding characters are needed ## DP: but the input string is terminated by CRLF, CR or LF. @DPATCH@ diff -urNad trunk~/lib/saslutil.c trunk/lib/saslutil.c --- trunk~/lib/saslutil.c 2006-12-01 13:52:33.000000000 +0200 +++ trunk/lib/saslutil.c 2006-12-05 10:36:25.000000000 +0200 @@ -222,12 +222,19 @@ } if (inlen != 0) { - if (saw_equal) { - /* Unless there is CRLF at the end? */ - return SASL_BADPROT; - } else { - return (SASL_CONTINUE); - } + /* check for trailing CRLF, CR or LF */ + if ( (inlen == 2 && in[0] == '\r' && in[1] == '\n') || + (inlen == 1 && in[0] == '\r') || + (inlen == 1 && in[0] == '\n') ) { + /* do nothing; exit the if structure and return successfully */ + ; + } else { + if (saw_equal) { + return SASL_BADPROT; + } else { + return (SASL_CONTINUE); + } + } } *out = '\0'; /* NUL terminate the output string */