Hi guys,

while updating the sendmail.tcl to also be capable of the simple AUTH PLAIN 
mechanism (if you have to use at least a basic form of relay control) 
I noticed a problem with ns_base64encode:

(1) Working:

~> perl -MMIME::Base64 -e 'print encode_base64("test\0test\0testpass");'
dGVzdAB0ZXN0AHRlc3RwYXNz

% package require base64
% ::base64::encode "test\0test\0testpass"
dGVzdAB0ZXN0AHRlc3RwYXNz

(2) Failing:

% ns_base64encode "test\0test\0testpass"
dGVzdMCAdGVzdMCAdGVzdHBhc3M=

In the particular AUTH PLAIN situation, where user, realm and pw are split by 
the null byte, the problem (one of the problems) is the missing null byte of 
the ns_uuencoded string:

~> perl -MMIME::Base64 -e 'print decode_base64
("dGVzdMCAdGVzdMCAdGVzdHBhc3M=");'|hexdump
0000000 6574 7473 80c0 6574 7473 80c0 6574 7473
0000010 6170 7373
0000014

and in the perl and tcllib example it works:

~> perl -MMIME::Base64 -e 'print decode_base64("dGVzdAB0ZXN0AHRlc3RwYXNz");'|
hexdump
0000000 6574 7473 7400 7365 0074 6574 7473 6170
0000010 7373
0000012

Do I miss something or could it be a bug?

-Bernd.

Reply via email to