Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d857cd89
Commit
d857cd89
authored
Sep 17, 2012
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql-5.5 to working copy.
parents
636224c4
7ccfd19a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
4 deletions
+98
-4
sql/hostname.cc
sql/hostname.cc
+54
-2
sql/sql_acl.cc
sql/sql_acl.cc
+31
-2
sql/sql_connect.cc
sql/sql_connect.cc
+13
-0
No files found.
sql/hostname.cc
View file @
d857cd89
...
...
@@ -366,6 +366,14 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
err_code
=
vio_getnameinfo
(
ip
,
hostname_buffer
,
NI_MAXHOST
,
NULL
,
0
,
NI_NAMEREQD
);
/* BEGIN : DEBUG */
DBUG_EXECUTE_IF
(
"addr_fake_ipv4"
,
{
strcpy
(
hostname_buffer
,
"santa.claus.ipv4.example.com"
);
err_code
=
0
;
};);
/* END : DEBUG */
if
(
err_code
)
{
// NOTE: gai_strerror() returns a string ending by a dot.
...
...
@@ -438,6 +446,12 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
DBUG_RETURN
(
err_status
);
}
/*
To avoid crashing the server in DBUG_EXECUTE_IF,
Define a variable which depicts state of addr_info_list.
*/
bool
free_addr_info_list
=
false
;
/* Get IP-addresses for the resolved host name (FCrDNS technique). */
struct
addrinfo
hints
;
...
...
@@ -452,6 +466,42 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
(
const
char
*
)
hostname_buffer
));
err_code
=
getaddrinfo
(
hostname_buffer
,
NULL
,
&
hints
,
&
addr_info_list
);
if
(
err_code
==
0
)
free_addr_info_list
=
true
;
/* BEGIN : DEBUG */
DBUG_EXECUTE_IF
(
"addr_fake_ipv4"
,
{
if
(
free_addr_info_list
)
freeaddrinfo
(
addr_info_list
);
struct
sockaddr_in
*
debug_addr
;
static
struct
sockaddr_in
debug_sock_addr
[
2
];
static
struct
addrinfo
debug_addr_info
[
2
];
/* Simulating ipv4 192.0.2.5 */
debug_addr
=
&
debug_sock_addr
[
0
];
debug_addr
->
sin_family
=
AF_INET
;
debug_addr
->
sin_addr
.
s_addr
=
inet_addr
(
"192.0.2.5"
);
/* Simulating ipv4 192.0.2.4 */
debug_addr
=
&
debug_sock_addr
[
1
];
debug_addr
->
sin_family
=
AF_INET
;
debug_addr
->
sin_addr
.
s_addr
=
inet_addr
(
"192.0.2.4"
);
debug_addr_info
[
0
].
ai_addr
=
(
struct
sockaddr
*
)
&
debug_sock_addr
[
0
];
debug_addr_info
[
0
].
ai_addrlen
=
sizeof
(
struct
sockaddr_in
);
debug_addr_info
[
0
].
ai_next
=
&
debug_addr_info
[
1
];
debug_addr_info
[
1
].
ai_addr
=
(
struct
sockaddr
*
)
&
debug_sock_addr
[
1
];
debug_addr_info
[
1
].
ai_addrlen
=
sizeof
(
struct
sockaddr_in
);
debug_addr_info
[
1
].
ai_next
=
NULL
;
addr_info_list
=
&
debug_addr_info
[
0
];
err_code
=
0
;
free_addr_info_list
=
false
;
};);
/* END : DEBUG */
if
(
err_code
==
EAI_NONAME
)
{
...
...
@@ -504,7 +554,8 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
{
DBUG_PRINT
(
"error"
,
(
"Out of memory."
));
freeaddrinfo
(
addr_info_list
);
if
(
free_addr_info_list
)
freeaddrinfo
(
addr_info_list
);
DBUG_RETURN
(
TRUE
);
}
...
...
@@ -538,7 +589,8 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
/* Free the result of getaddrinfo(). */
freeaddrinfo
(
addr_info_list
);
if
(
free_addr_info_list
)
freeaddrinfo
(
addr_info_list
);
/* Add an entry for the IP to the cache. */
...
...
sql/sql_acl.cc
View file @
d857cd89
...
...
@@ -8540,8 +8540,6 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
bool
packet_has_required_size
=
false
;
DBUG_ASSERT
(
mpvio
->
status
==
MPVIO_EXT
::
FAILURE
);
if
(
mpvio
->
connect_errors
)
reset_host_errors
(
mpvio
->
ip
);
uint
charset_code
=
0
;
end
=
(
char
*
)
net
->
read_pos
;
...
...
@@ -8552,6 +8550,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
*/
size_t
bytes_remaining_in_packet
=
pkt_len
;
DBUG_EXECUTE_IF
(
"host_error_packet_length"
,
{
bytes_remaining_in_packet
=
0
;
};);
/*
Peek ahead on the client capability packet and determine which version of
the protocol should be used.
...
...
@@ -8609,6 +8612,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
*/
charset_code
=
default_charset_info
->
number
;
}
DBUG_EXECUTE_IF
(
"host_error_charset"
,
{
return
packet_error
;
};);
DBUG_PRINT
(
"info"
,
(
"client_character_set: %u"
,
charset_code
));
if
(
mpvio
->
charset_adapter
->
init_client_charset
(
charset_code
))
...
...
@@ -8671,6 +8679,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
bytes_remaining_in_packet
-=
AUTH_PACKET_HEADER_SIZE_PROTO_40
;
}
DBUG_EXECUTE_IF
(
"host_error_SSL_layering"
,
{
packet_has_required_size
=
0
;
};);
if
(
!
packet_has_required_size
)
return
packet_error
;
}
...
...
@@ -8702,6 +8715,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
size_t
user_len
;
char
*
user
=
get_string
(
&
end
,
&
bytes_remaining_in_packet
,
&
user_len
);
DBUG_EXECUTE_IF
(
"host_error_user"
,
{
user
=
NULL
;
};);
if
(
user
==
NULL
)
return
packet_error
;
...
...
@@ -8729,6 +8747,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
passwd
=
get_string
(
&
end
,
&
bytes_remaining_in_packet
,
&
passwd_len
);
}
DBUG_EXECUTE_IF
(
"host_error_password"
,
{
passwd
=
NULL
;
};);
if
(
passwd
==
NULL
)
return
packet_error
;
...
...
@@ -9527,6 +9550,12 @@ acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_len)
thd
->
net
.
skip_big_packet
=
TRUE
;
#endif
/*
Reset previous connection failures if any.
*/
if
(
mpvio
.
connect_errors
)
reset_host_errors
(
mpvio
.
ip
);
/* Ready to handle queries */
DBUG_RETURN
(
0
);
}
...
...
sql/sql_connect.cc
View file @
d857cd89
...
...
@@ -499,6 +499,19 @@ static int check_connection(THD *thd)
my_error
(
ER_BAD_HOST_ERROR
,
MYF
(
0
));
return
1
;
}
/* BEGIN : DEBUG */
DBUG_EXECUTE_IF
(
"addr_fake_ipv4"
,
{
struct
sockaddr
*
sa
=
(
sockaddr
*
)
&
net
->
vio
->
remote
;
sa
->
sa_family
=
AF_INET
;
struct
in_addr
*
ip4
=
&
((
struct
sockaddr_in
*
)
sa
)
->
sin_addr
;
/* See RFC 5737, 192.0.2.0/23 is reserved */
const
char
*
fake
=
"192.0.2.4"
;
ip4
->
s_addr
=
inet_addr
(
fake
);
strcpy
(
ip
,
fake
);
};);
/* END : DEBUG */
if
(
!
(
thd
->
main_security_ctx
.
ip
=
my_strdup
(
ip
,
MYF
(
MY_WME
))))
return
1
;
/* The error is set by my_strdup(). */
thd
->
main_security_ctx
.
host_or_ip
=
thd
->
main_security_ctx
.
ip
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment