Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null descriptor strings #3

Open
ghost opened this issue Jul 12, 2016 · 0 comments
Open

Null descriptor strings #3

ghost opened this issue Jul 12, 2016 · 0 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jul 12, 2016

It appears possible to have null strings in the dex format, unsure if this is the result of a malformed dex or not.

2E 00 1C 41 77 61 6B 65 54 69 6D 65 53 69 6E 63 65 42 6F 6F 74 43 6C 6F 63 6B 2E 6A 61 76 61 00 00 00 01 42 00 13 42 41 43 4B 47 52 4F 55 4E 44 5F 4C 4F 43 41 54 49 4F 4E 00

note '00 00' at offset 32.

Subsequently, when DexReader:PrefetchTypeReferences is called, the function TypeDescriptor.Allocate is used to consume this null string, which in turn returns a null type descriptor, which is then added to the TypeReferences list.

This becomes problematic later on, when https://github.com/sailro/Dexer/blob/master/Dexer/IO/DexReader.cs#L201 is called, as it means Dex.TypeReferences[classIndex] can actually be null.

To combat this, we can improve checking on null values within DexReader (line 201), this way we maintain the requirement of keeping indexing into TypeReferences viable:

                    if (reference == null)
                    {
                        ClassDefinition cdef = new ClassDefinition();
                        var reference2 = Dex.TypeReferences[classIndex] as ClassReference;
                        // use empty object
                        if (reference2 == null)
                            cdef = null;
                        else
                            cdef = new ClassDefinition(reference2);

                        Dex.TypeReferences[classIndex] = cdef;
                        Dex.Classes.Add(cdef);
                    }

Unfortunately this wreaks havoc later on when TypeDescriptor.Fill (

internal static void Fill(string tdString, TypeReference item, Dex context)
) NPR's in context.Import as TypeReference (item) can be null.

I am not 100% sure how to progress this one, but will keep this issue to track the problem.

@sailro sailro added the bug label Aug 3, 2016
@sailro sailro self-assigned this Aug 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant