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)
{
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 protocol_major = 11; // TODO: config? env?
var protocol_minor = 0;
stream.pack(
'CxSSSSxxaa',
'CxSSSSxxpp',
[
byte_order,
protocol_major,
@ -205,4 +203,4 @@ function writeClientHello(stream, displayNum, authHost)
}
module.exports.readServerHello = readServerHello;
module.exports.writeClientHello = writeClientHello;
module.exports.writeClientHello = writeClientHello;

View file

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