Skip to content

Commit 5151820

Browse files
blauddendahlerlend
authored andcommitted
Bug#36005903 mgmapi failure to parse bindadress
Bug#36018640 Test UnresolvedHosts2 passes but ndbd aborts and dumps core (Merge mysql-trunk => mysql-8.3.0) Change-Id: I6c65d7b4208a026cfc39e48fe34dbc3dcd7ea002
1 parent 7d3791a commit 5151820

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

storage/ndb/src/mgmapi/mgmapi-t.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <mgmapi/mgmapi.h>
2828
#include <mgmapi/mgmapi_debug.h>
2929
#include "mgmapi_internal.h"
30+
#include "mgmcommon/NdbMgm.hpp"
3031

3132
TAPTEST(mgmapi) {
3233
// Check behaviour of error translation functions with NULL handle
@@ -128,5 +129,18 @@ TAPTEST(mgmapi) {
128129
// Destroy handle
129130
ndb_mgm_destroy_handle(&h);
130131

132+
// Check parsing of bind address, with and without port
133+
// Neither bindaddress or port is possible to check, only return code
134+
{
135+
ndb_mgm::handle_ptr handle(ndb_mgm_create_handle());
136+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost") == 0);
137+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost:12345") == 0);
138+
// Illegal values
139+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost:65536") == -1);
140+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost:-5") == -1);
141+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost:mysql") == -1);
142+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost:2147483648") == -1);
143+
OK(ndb_mgm_set_bindaddress(handle.get(), "localhost:-2147483649") == -1);
144+
}
131145
return 1; // OK
132146
}

storage/ndb/src/mgmapi/mgmapi.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,17 @@ extern "C" int ndb_mgm_set_connectstring(NdbMgmHandle handle,
281281
extern "C" int ndb_mgm_set_bindaddress(NdbMgmHandle handle, const char *arg) {
282282
DBUG_ENTER("ndb_mgm_set_bindaddress");
283283
free(handle->m_bindaddress);
284+
handle->m_bindaddress = nullptr;
285+
handle->m_bindaddress_port = 0;
284286

285287
if (arg) {
286288
char hostbuf[NI_MAXHOST];
287289
char servbuf[NI_MAXSERV];
288290
if (Ndb_split_string_address_port(arg, hostbuf, sizeof(hostbuf), servbuf,
289291
sizeof(servbuf)) == 0) {
290292
char *endp = nullptr;
291-
errno = 0;
292293
long val = strtol(servbuf, &endp, 10);
293-
294-
if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) ||
295-
(errno != 0) || (*endp != '\0') || (val > UINT16_MAX) || (val < 0)) {
294+
if (*endp != '\0' || val > UINT16_MAX || val < 0) {
296295
// invalid address
297296
SET_ERROR(handle, NDB_MGM_ILLEGAL_BIND_ADDRESS, "Illegal bind address");
298297
DBUG_RETURN(-1);
@@ -305,9 +304,6 @@ extern "C" int ndb_mgm_set_bindaddress(NdbMgmHandle handle, const char *arg) {
305304
SET_ERROR(handle, NDB_MGM_ILLEGAL_BIND_ADDRESS, "Illegal bind address");
306305
DBUG_RETURN(-1);
307306
}
308-
} else {
309-
handle->m_bindaddress = nullptr;
310-
handle->m_bindaddress_port = 0;
311307
}
312308
if (handle->cfg.ids.size() != 0) {
313309
handle->cfg.bind_address_port = handle->m_bindaddress_port;
@@ -428,11 +424,11 @@ static const Properties *handle_authorization_failure(NdbMgmHandle handle,
428424
ndb_mgmd.
429425
Read and return result
430426
431-
@param The mgmapi handle
432-
@param List describing the expected reply
433-
@param Name of the command to call
434-
@param Arguments for the command
435-
@param Any bulk data to send after the command
427+
@param handle The mgmapi handle
428+
@param command_reply List describing the expected reply
429+
@param cmd Name of the command to call
430+
@param cmd_args Arguments for the command
431+
@param cmd_bulk Any bulk data to send after the command
436432
437433
*/
438434
static const Properties *ndb_mgm_call(

storage/ndb/test/ndbapi/testMgmd.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class Ndbd : public Mgmd {
328328
Ndbd(int nodeid) : Mgmd(nodeid), m_args() {
329329
m_args.add("--ndb-nodeid=", m_nodeid);
330330
m_args.add("--foreground");
331+
m_args.add("--loose-core-file=0");
331332
m_name.assfmt("ndbd_%d", nodeid);
332333
NDBT_find_ndbd(m_exe);
333334
}

0 commit comments

Comments
 (0)