fix for incorrect length of authType & authData strings in handshake

This commit is contained in:
Andrey Sidorov 2011-11-25 23:25:02 +01:00
parent 956ba1e241
commit d24332c90f
2 changed files with 4 additions and 6 deletions

View file

@ -183,13 +183,11 @@ bl.unpack('C', function(res) {
function writeClientHello(stream, displayNum, authHost) function writeClientHello(stream, displayNum, authHost)
{ {
getAuthString( displayNum, authHost, function( authType, authData ) { getAuthString( displayNum, authHost, function( authType, authData ) {
authType = xutil.padded_string( authType );
authData = xutil.padded_string( authData );
var byte_order = 'l'.charCodeAt(0); // TODO: byteorder!!! var byte_order = 'l'.charCodeAt(0); // TODO: byteorder!!!
var protocol_major = 11; // TODO: config? env? var protocol_major = 11; // TODO: config? env?
var protocol_minor = 0; var protocol_minor = 0;
stream.pack( stream.pack(
'CxSSSSxxaa', 'CxSSSSxxpp',
[ [
byte_order, byte_order,
protocol_major, protocol_major,

View file

@ -273,11 +273,11 @@ UnpackStream.prototype.pack = function(format, args)
break; break;
case 'p': // padded string case 'p': // padded string
var str = args[arg++]; var str = args[arg++];
var len = padded(str); var len = xutil.padded_length(str.length);
// TODO: buffer.write could be faster // TODO: buffer.write could be faster
var c = 0; var c = 0;
for (; c < str.length; ++c) for (; c < str.length; ++c)
buf[offset++] = str[c]; buf[offset++] = str.charCodeAt(c);
for (; c < len; ++c) for (; c < len; ++c)
buf[offset++] = 0; buf[offset++] = 0;
break; break;