1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
| visrc/network-mysqld-packet.c
1139network_mysqld_auth_challenge *network_mysqld_auth_challenge_new() {
1140 network_mysqld_auth_challenge *shake;
1141
1142 shake =g_new0(network_mysqld_auth_challenge, 1);
1143
1144 shake->challenge =g_string_sized_new(20);
1145 shake->capabilities =
1146 CLIENT_PROTOCOL_41 |
1147 CLIENT_SECURE_CONNECTION |
1148 0;
1149
1150
1151 return shake;
1152 }
修改1147行为如下:
1139network_mysqld_auth_challenge *network_mysqld_auth_challenge_new() {
1140 network_mysqld_auth_challenge *shake;
1141
1142 shake =g_new0(network_mysqld_auth_challenge, 1);
1143
1144 shake->challenge =g_string_sized_new(20);
1145 shake->capabilities =
1146 CLIENT_PROTOCOL_41 |
1147 CLIENT_RESERVED2 |
1148 0;
1149
1150
1151 return shake;
1152 }
1220
1221 if (shake->capabilities &CLIENT_SECURE_CONNECTION) {
1222 err = err ||network_mysqld_proto_get_string_len(packet, &scramble_2, 12);
1223 err = err ||network_mysqld_proto_skip(packet, 1);
1224 }
1225
1226 if (!err) {
1227 /* process the data */
1228
1229 if (3 !=sscanf(shake->server_version_str, "%d.%d.%d%*s", &maj,&min, &patch)) {
1230 /* can't parse theprotocol */
1231
1232 g_critical("%s:protocol 10, but version number not parsable", G_STRLOC);
1233
1234 return -1;
1235 }
1236
修改1221行为如下:
1220
1221 if (shake->capabilities & CLIENT_RESERVED2) {
1222 err = err ||network_mysqld_proto_get_string_len(packet, &scramble_2, 12);
1223 err = err ||network_mysqld_proto_skip(packet, 1);
1224 }
1225
1226 if (!err) {
1227 /* process the data */
1228
1229 if (3 !=sscanf(shake->server_version_str, "%d.%d.%d%*s", &maj,&min, &patch)) {
1230 /* can't parse theprotocol */
1231
1232 g_critical("%s:protocol 10, but version number not parsable", G_STRLOC);
1233
1234 return -1;
1235 }
1236
1312network_mysqld_auth_response *network_mysqld_auth_response_new() {
1313 network_mysqld_auth_response *auth;
1314
1315 auth =g_new0(network_mysqld_auth_response, 1);
1316
1317 /* we have to make surescramble->buf is not-NULL to get
1318 * the "empty string" andnot a "NULL-string"
1319 */
1320 auth->response =g_string_new("");
1321 auth->username =g_string_new("");
1322 auth->database =g_string_new("");
1323 auth->capabilities =CLIENT_SECURE_CONNECTION | CLIENT_PROTOCOL_41;
1324
1325 return auth;
1326 }
修改1323行为如下:
1312network_mysqld_auth_response *network_mysqld_auth_response_new() {
1313 network_mysqld_auth_response *auth;
1314
1315 auth =g_new0(network_mysqld_auth_response, 1);
1316
1317 /* we have to make surescramble->buf is not-NULL to get
1318 * the "empty string" andnot a "NULL-string"
1319 */
1320 auth->response =g_string_new("");
1321 auth->username =g_string_new("");
1322 auth->database =g_string_new("");
1323 auth->capabilities = CLIENT_RESERVED2 | CLIENT_PROTOCOL_41;
1324
1325 return auth;
1326 }
1378 if (auth->capabilities& CLIENT_SECURE_CONNECTION) {
1379 err = err ||network_mysqld_proto_get_lenenc_gstring(packet, auth->response);
1380 } else {
1381 err = err ||network_mysqld_proto_get_gstring(packet, auth->response);
1382 }
1383
1384 if (packet->offset !=packet->data->len) {
1385 /* database isoptional and may include a trailing \0 char */
1386 err = err ||network_mysqld_proto_get_gstring_len
修改1378行为如下:
1378 if (auth->capabilities& CLIENT_RESERVED2) {
1379 err = err ||network_mysqld_proto_get_lenenc_gstring(packet, auth->response);
1380 } else {
1381 err = err ||network_mysqld_proto_get_gstring(packet, auth->response);
1382 }
1383
1384 if (packet->offset !=packet->data->len) {
1385 /* database isoptional and may include a trailing \0 char */
1386 err = err ||network_mysqld_proto_get_gstring_len
viplugins/admin/admin-plugin.c
195NETWORK_MYSQLD_PLUGIN_PROTO(server_con_init) {
196 network_mysqld_auth_challenge*challenge;
197 GString *packet;
198
199 challenge =network_mysqld_auth_challenge_new();
200 challenge->server_version_str =g_strdup("5.0.99-agent-admin");
201 challenge->server_version = 50099;
202 challenge->charset = 0x08; /* latin1 */
203 challenge->capabilities = CLIENT_PROTOCOL_41 |CLIENT_SECURE_CONNECTION | CLIENT_LONG_PASSWORD;
204 challenge->server_status = SERVER_STATUS_AUTOCOMMIT;
205 challenge->thread_id = 1;
修改203行为如下:
195NETWORK_MYSQLD_PLUGIN_PROTO(server_con_init) {
196 network_mysqld_auth_challenge*challenge;
197 GString *packet;
198
199 challenge =network_mysqld_auth_challenge_new();
200 challenge->server_version_str =g_strdup("5.0.99-agent-admin");
201 challenge->server_version = 50099;
202 challenge->charset = 0x08; /* latin1 */
203 challenge->capabilities = CLIENT_PROTOCOL_41 | CLIENT_RESERVED2 | CLIENT_LONG_PASSWORD;
204 challenge->server_status = SERVER_STATUS_AUTOCOMMIT;
205 challenge->thread_id = 1;
|