Skip to content

Crash when parsing _lengthy_ beacon data fields #1185

Description

@gerardmundo-birket

(First off, thank you for this fantastic library. I appreciate everyone's efforts into making this library better everyday. I am truly thankful for your time invested and for sharing all your expertise)

Expected behavior

Parsing of lengthy data fields succeeds

Actual behavior

Crash due to Java Long java.lang.NumberFormatException

Steps to reproduce this behavior

In lines 644 & 645 of BeaconParser.java, a hexadecimal string is created (because the data field is >= 5 bytes) but the function Long.decode expects a radix specifier ("0x", "0X" or "#" for hexadecimal) in front of the string.

This is due to the function byteArrayToFormattedString converting data fields longer than 4 bytes to hexadecimal. Additionally, if the length is 16, it even adds dashes which can also not be "decoded" by the Long function.

Finally, if the data fields are being inserted into a Long number, I expect there to be a length limitation, but I don't see that documented (it doesn't seem to be enforced in the code either, if I am not mistaken).

I can provide examples if desired.

Android Beacon Library version

Code from Master branch

Again... thank you!

Activity

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