Browse Source

Fixed host name comparison (still Bug #17582)

pull/73/head
hartmut@mysql.com/linux.site 19 years ago
parent
commit
d214ec09d1
  1. 3
      mysql-test/r/ndb_config.result
  2. 5
      mysql-test/t/ndb_config.test
  3. 23
      ndb/tools/ndb_config.cpp

3
mysql-test/r/ndb_config.result

@ -9,3 +9,6 @@ ndbd,1,localhost ndbd,2,localhost ndbd,3,localhost ndbd,4,localhost ndb_mgmd,5,l
ndbd,2,localhost ndbd,3,localhost ndbd,4,localhost ndbd,5,localhost ndb_mgmd,6,localhost mysqld,1, mysqld,7, mysqld,8, mysqld,9, mysqld,10,
ndbd,3,localhost ndbd,4,localhost ndbd,5,localhost ndbd,6,localhost ndb_mgmd,1,localhost ndb_mgmd,2,localhost mysqld,11, mysqld,12, mysqld,13, mysqld,14, mysqld,15,
shm,3,4,35,3 shm,3,5,35,3 shm,3,6,35,3 shm,4,5,35,4 shm,4,6,35,4 shm,5,6,35,5 tcp,11,3,55,3 tcp,11,4,55,4 tcp,11,5,55,5 tcp,11,6,55,6 tcp,12,3,55,3 tcp,12,4,55,4 tcp,12,5,55,5 tcp,12,6,55,6 tcp,13,3,55,3 tcp,13,4,55,4 tcp,13,5,55,5 tcp,13,6,55,6 tcp,14,3,55,3 tcp,14,4,55,4 tcp,14,5,55,5 tcp,14,6,55,6 tcp,15,3,55,3 tcp,15,4,55,4 tcp,15,5,55,5 tcp,15,6,55,6 tcp,1,3,55,1 tcp,1,4,55,1 tcp,1,5,55,1 tcp,1,6,55,1 tcp,2,3,55,2 tcp,2,4,55,2 tcp,2,5,55,2 tcp,2,6,55,2
1 2 3
1 2 3

5
mysql-test/t/ndb_config.test

@ -16,3 +16,8 @@
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster1 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=localhost --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=1.2.3.4 --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=127.0.0.1 --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null

23
ndb/tools/ndb_config.cpp

@ -411,28 +411,43 @@ HostMatch::eval(const Iter& iter)
if(iter.get(m_key, &valc) == 0)
{
struct hostent *h1, *h2;
struct hostent *h1, *h2, copy1;
char *addr1;
int stat;
h1 = gethostbyname(m_value.c_str());
if (h1 == NULL) {
return 0;
}
// gethostbyname returns a pointer to a static structure
// so we need to copy the results before doing the next call
memcpy(&copy1, h1, sizeof(struct hostent));
addr1 = (char *)malloc(copy1.h_length);
memcpy(addr1, h1->h_addr, copy1.h_length);
h2 = gethostbyname(valc);
if (h2 == NULL) {
free(addr1);
return 0;
}
if (h1->h_addrtype != h2->h_addrtype) {
if (copy1.h_addrtype != h2->h_addrtype) {
free(addr1);
return 0;
}
if (h1->h_length != h2->h_length)
if (copy1.h_length != h2->h_length)
{
free(addr1);
return 0;
}
return 0 == memcmp(h1->h_addr, h2->h_addr, h1->h_length);
stat = memcmp(addr1, h2->h_addr, copy1.h_length);
free(addr1);
return (stat == 0);
}
return 0;

Loading…
Cancel
Save