Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions MySQL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ sub _get_server_information
$i += 4;
$self->{salt} = substr $message, $i, 8;
#
$self->{saltold} = $self->{salt};
#
$i += 8+1;
if (length $message >= $i + 1) {
$i += 1;
Expand Down Expand Up @@ -256,7 +258,19 @@ sub _request_authentication
croak "Timeout of authentication";
}
croak substr $auth_result, 7;
}
} elsif (ord(substr $auth_result, 4) == 254 ) {
$self->_send_password();
$mysql->recv($auth_result, BUFFER_LENGTH, 0);
$self->_dump_packet($auth_result) if Net::MySQL->debug;
if ($self->_is_error($auth_result)) {
$mysql->close;
if (length $auth_result < 7) {
croak "Timeout of authentication";
}
croak substr $auth_result, 7;
}

}
print "connect database\n" if Net::MySQL->debug;
}

Expand All @@ -281,6 +295,21 @@ sub _send_login_message
}


sub _send_password
{
my $self = shift;
my $mysql = $self->{socket};
my $body = "\0\0\x03".
Net::MySQL::Password32->scramble(
$self->{password}, $self->{saltold}, $self->{client_capabilities}
);
$body .= "\0";
my $pw_message = chr(length($body)-3). $body;
$mysql->send($pw_message, 0);
$self->_dump_packet($pw_message) if Net::MySQL->debug;
}



sub _execute_command
{
Expand Down Expand Up @@ -457,7 +486,7 @@ sub _has_next_packet
my $self = shift;
#substr($_[0], -1) ne "\xfe";
#$self->_dump_packet(substr($_[0], -5));
return substr($_[0], -5, 1) ne "\xfe";
return (substr($_[0],-5) ne "\xfe\0\0\x02\x00" and substr($_[0], -5) ne "\xfe\0\0\x22\x00");
}


Expand Down