Projects tigase _server server-core Issues #935
tigase.server.BasicComponent#getDefHostName seems to return empty/invalid value (#935)
Closed
wojciech.kapcia@tigase.net opened 6 years ago

It seems that tigase.server.BasicComponent#getDefHostName returns either empty or invalid value. Occurances with version 7.1.4 and 7.1.3-SNAPSHOT.

Andrzej Wójcik (Tigase) commented 6 years ago

I've looked for possible causes of this issue and for me it looks like the only way for getDefHostName() to return empty JID (BareJID with empty domain part) is caused by settings -Dtigase-primary-address to an empty value (adding -Dtigase-primary-address= to Tigase options in tigase.conf.

This is caused by the fact that InetAddress::getByName(tigasePrimaryHost) is NOT throwing an exception if tigasePrimaryHost is set to an empty string, causing Tigase to accept this empty string as default hostname.

Additionally, BareJID accepts domain of BareJID to be an empty string. In my opinion, this should not be allowed and we should:

  • throw TigaseStringprepException for methods bareJIDInstance()
  • return null for methods bareJIDInstanceNS (or throw NPE)

I think that we should also check if tigase-secondary-address does not have similar issues.

wojciech.kapcia@tigase.net commented 6 years ago

Andrzej Wójcik wrote:

I've looked for possible causes of this issue and for me it looks like the only way for getDefHostName() to return empty JID (BareJID with empty domain part) is caused by settings -Dtigase-primary-address to an empty value (adding -Dtigase-primary-address= to Tigase options in tigase.conf.

This is caused by the fact that InetAddress::getByName(tigasePrimaryHost) is NOT throwing an exception if tigasePrimaryHost is set to an empty string, causing Tigase to accept this empty string as default hostname.

Thank you for pointing this out - I fixed both places in stable and master.

Additionally, BareJID accepts domain of BareJID to be an empty string. In my opinion, this should not be allowed and we should:

  • throw TigaseStringprepException for methods bareJIDInstance()
  • return null for methods bareJIDInstanceNS (or throw NPE)

You are correct according to 2.2. Domainpart:

it is the primary identifier and is the only **REQUIRED** element of a JID (a mere domainpart is a valid JID)

I added checks in JIDInstance methods and accompanying tests.

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
6911
Version
tigase-server-7.1.4
Spent time
21h 15m
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#935
Please wait...
Page is in error, reload to recover