Skip to content

IllegalArgumentException from minidns-hla 0.3.4 #104

Open

Description

@quite

I've seen this in my app Mumla. Got a stack trace from a user, sent to me by gôôg play. I'm using 0.3.4 from jcenter which apparently is not tagged in this repo (!).
Have #70 been resurrected?

java.lang.IllegalArgumentException: 
  _at java.net.IDN.toASCII (IDN.java:115)
  _at java.net.IDN.toASCII (IDN.java:138)
  at org.minidns.idna.DefaultIdnaTransformator.toASCII (DefaultIdnaTransformator.java:28)
  at org.minidns.idna.MiniDnsIdna.toASCII (MiniDnsIdna.java:18)
  at org.minidns.dnsname.DnsName.<init> (DnsName.java:126)
  at org.minidns.dnsname.DnsName.from (DnsName.java:331)
  at org.minidns.hla.ResolverApi.resolveSrv (ResolverApi.java:140)
  at se.lublin.humla.model.Server$2.run (Server.java:200)
  _at java.lang.Thread.run (Thread.java:929)
  _at android.icu.impl.IDNA2003.convertToASCII
  _at android.icu.impl.IDNA2003.convertIDNToASCII (IDNA2003.java:277)
  _at android.icu.text.IDNA.convertIDNToASCII (IDNA.java:654)
  _at java.net.IDN.toASCII (IDN.java:108)

(lines marked with _ are lighter gray in the report)

This is my code:

final String lookup = "_mumble._tcp." + srvHost.get();
SrvResolverResult res = ResolverApi.INSTANCE.resolveSrv(lookup);
if (!res.wasSuccessful()) {

Unfortunately I cannot see what srvHost it was, from user input...

Activity

  1. Flowdalic commented on Jun 24, 2020

    @Flowdalic
    Collaborator

    Thanks for your report.

    I'm using 0.3.4 from jcenter which apparently is not tagged in this repo (!).

    Thanks for pointing this out. I have just pushed the 0.3.4 tag.

    Have #70 been resurrected?

    I am not sure about that. #70 was caused by Android bug https://issuetracker.google.com/issues/113070416 for which have

    // Special case if input is ".", i.e. a string containing only a single dot character. This is a workaround for
    // IDN.toASCII() implementations throwing an IllegalArgumentException on this input string (for example Android
    // APIs level 26).
    if (DnsName.ROOT.ace.equals(input)) {
    return DnsName.ROOT.ace;
    }
    in place.

    The stacktrace has some noticeable characteristics: First, is the exception's message really the empty string? And why does it look like convertToASCII is calling Thread.run()?

    If we would know the used Android version, we could look into AOSP and see what is triggering the IAE at IDN.java:115.

    Thanks for using MiniDNS btw. Especially for a mumble related project, which I currently use nearly daily. Please feel hereby encouraged to try out the latest minidns 0.4 alpha: 0.4.0-alpha6. I has many Android related improvements, and even though it is an alpha version, it runs pretty stable. And the MiniDNS project needs testers who can provide feedback. I think you could use it in production, but an other option would be to integrate the new MiniDNS version in your staging/development branch of your app.

    BTW, I noticed that you do not include minidns-android21 in your project. You really should do so, and call AndroidUsingLinkProperties setup(Context context) before the first DNS lookup.

  2. quite commented on Jun 24, 2020

    @quite
    Author
  3. Flowdalic commented on Jun 24, 2020

    @Flowdalic
    Collaborator

    Where is a message supposed to be? I pasted what I got.

    It is printed right after the exception class. I.e.,
    java.lang.IllegalArgumentException: <here would be the exception message>

    Since IDN.java:115 is https://android.googlesource.com/platform/libcore/+/master/ojluni/src/main/java/java/net/IDN.java#115
    it appears we are missing the complete exception message. Which is sad, since it contains the crucial information.

    We may run into the same issue okhttp has experienced: lysine-dev/okhttp#5840

    Android 10's IDN.toASCII() does stricter enforcing, which itself is appears correct. MiniDNS eventually should not call toASCII() on Non-LDH DNS labels. Which, on the other hand, does not appear to be trivial, since toASCII() is currently called by MiniDNS with the full DNS name, and not with individual labels. However, I think to ASCII() should operate on individual labels, and not on the full DNS name.

    I see if I can push a fix for this.

    Mmm, I might try that when I get time. I was cautious about the "alpha" obviously...

    I know, but if everyone waits until the official release, then the only difference between an alpha release and a release is just the string. ;)

  4. quite commented on Jun 24, 2020

    @quite
    Author

    it appears we are missing the complete exception message. Which is sad, since it contains the crucial information.

    Goog is stripping it and it is no longer possible to get hold of (it used to be available in some downloadable reports). Perhaps devs stuffed integrity problematic things into it.... or goog is just pushing towards use of Firebase Crashlytics, which seems to have more detailed crash reports.

    We may run into the same issue okhttp has experienced: lysine-dev/okhttp#5840

    I skimmed very quickly through that... But underscores does work, at least in the _mumble._tcp part.

    MiniDNS eventually should not call to on Non-LDH DNS labels

    Should that be "should call toASCII() only on non-LDH DNS labels"? (LDH being letters, digits, hyphen, right? but not underscore).

    Could the issue be a label with international unicode letters plus underscore? Do they exist? Well, they can surely be input... Just thinking aloud.

  5. Flowdalic commented on Jun 24, 2020

    @Flowdalic
    Collaborator

    Could the issue be a label with international unicode letters plus underscore? Do they exist?

    That is very well possible. Underscore(s) (U+00EF) are not allowed in U-Labels, see RFC 5892 § B.1:
    003A..0060 ; DISALLOWED # COLON..GRAVE ACCENT
    but I can not rule out that you find those in the wild.

    Fun fact: They are, however, allowed in DNS labels. Any byte is allowed in DNS labels. They are not allowed in LDH labels, obviously. But all that is not relevant here.

    Eventually, I am afraid, there is not much I can do right now, as the causing String is not know.

  6. quite commented on Jun 24, 2020

    @quite
    Author
  7. Flowdalic commented on Jun 25, 2020

    @Flowdalic
    Collaborator

    Ultimately this means that you want to wrap the call in a try/catch block and catch the IllegalArgumentException.

  8. quite commented on Jun 25, 2020

    @quite
    Author

    Yup, I did that just now.

    I also found this in the syslog! It seems to error on the empty label that I typed by mistake! Not intl unicode.

    FATAL EXCEPTION: Thread-32
    Process: se.lublin.mumla, PID: 28768
    java.lang.IllegalArgumentException: Invalid input to toASCII: _mumble._tcp..k_ö.com
            at java.net.IDN.toASCII(IDN.java:115)
            at java.net.IDN.toASCII(IDN.java:138)
            at org.minidns.idna.DefaultIdnaTransformator.toASCII(DefaultIdnaTransformator.java:28)
            at org.minidns.idna.MiniDnsIdna.toASCII(MiniDnsIdna.java:18)
            at org.minidns.dnsname.DnsName.<init>(DnsName.java:126)
            at org.minidns.dnsname.DnsName.from(DnsName.java:331)
            at org.minidns.hla.ResolverApi.resolveSrv(ResolverApi.java:140)
            at se.lublin.humla.model.Server$2.run(Server.java:200)
            at java.lang.Thread.run(Thread.java:919)
    Caused by: Found zero length lable after NamePrep.. line:  0. preContext:  . postContext:
    
            at android.icu.impl.IDNA2003.convertToASCII(IDNA2003.java:187)
            at android.icu.impl.IDNA2003.convertIDNToASCII(IDNA2003.java:277)
            at android.icu.text.IDNA.convertIDNToASCII(IDNA.java:654)
            at java.net.IDN.toASCII(IDN.java:108)
            ... 8 more
    
  9. quite commented on Aug 1, 2020

    @quite
    Author

    Wondering if this is an issue in 0.4.0. Guess I'd just have to try :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions