Skip to content

IndexOutOfBoundsException in NamedProperties.getPropertyName #7

Description

@remkop

IndexOutOfBoundsException in method io.github.jmcleodfoss.msg.NamedProperties::getPropertyName

Validation at the beginning of the method checks entries.length but does not check guids.length:

// NamedProperties.guids is initialized to an array with 6 elements;
// propertyIndex has value 6...   resulting in IndexOutOfBoundsException 

// FYI: Property::factory read propertyTag=0xFFFF_FFFF_8006_001F, propertyId=0x8006, propertyIndex=6

String getPropertyName(int propertyIndex) 
{
    if (propertyIndex >= entries.length)
        return String.format("Out of bounds error (%d >= %d", propertyIndex, entries.length);

    if (entries[propertyIndex].propertyType == EntryStreamEntry.PropertyType.STRING_NAMED_PROPERTY)
        return stringsByOffset.get(entries[propertyIndex].nameIdentifierOrStringOffset);

    if (PropertyLIDs.lids.keySet().contains(entries[propertyIndex].nameIdentifierOrStringOffset)) {
        GUID guid = PropertyLIDs.guids.get(entries[propertyIndex].nameIdentifierOrStringOffset);

        // FYI: `entries[propertyIndex]` has value "0x00008581 property index 0x0006 GUID index 0x0004 Numerical named property"
        // FYI: `entries[propertyIndex].nameIdentifierOrStringOffset` has value 0x00008581
        // FYI: `guid` has value "00062008-0000-0000-c000-000000000046" (which matches NamedProperties.guids[1] )

        if (guid != null && guid.equals(guids[propertyIndex])) { // <------ java.lang.IndexOutOfBoundsException : Invalid array range: 6 to 6
            return PropertyLIDs.lids.get(entries[propertyIndex].nameIdentifierOrStringOffset);
        }
    }
...

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions