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

drop out-of-bounds parameters in the dropInvalidMappings command #161

Open
ix0rai opened this issue Nov 6, 2023 · 7 comments
Open

drop out-of-bounds parameters in the dropInvalidMappings command #161

ix0rai opened this issue Nov 6, 2023 · 7 comments
Labels
cli affects the enigma command-line interface enhancement New feature or request

Comments

@ix0rai
Copy link
Member

ix0rai commented Nov 6, 2023

when methods change to and from static, it can occasionally leave parameters with indices that are outside of the method's parameter bounds. this means that those parameters are useless and just take up space in mappings -- they should be tossed

@ix0rai ix0rai added enhancement New feature or request cli affects the enigma command-line interface labels Nov 6, 2023
@IotaBread
Copy link
Member

Since #168 they are dropped if their index is lower than the minimum. Information from the bytecode is required for the maximum

if (this.hasMethod(parent)) {
// TODO: Check using max_locals from the Code attribute (JVMS§4.7.3)
AccessFlags parentAccess = this.getMethodAccess(parent);
int startIndex = parentAccess != null && parentAccess.isStatic() ? 0 : 1;
return localVariableEntry.getIndex() >= startIndex;
}

@OroArmor
Copy link
Member

OroArmor commented Jan 4, 2024

finding the number of parameters is hard since it spills over into the LVT

@OroArmor
Copy link
Member

OroArmor commented Jan 4, 2024

I just realized you can parse the descriptor and figure it out that way (plus knowing if its a static vs instance method)

@ix0rai
Copy link
Member Author

ix0rai commented Jan 4, 2024

am I insane? the issue I ran into implementing this is knowing if it was static based on the descriptor

@OroArmor
Copy link
Member

OroArmor commented Jan 4, 2024

I dont think there is a way to know unless you have indexed the jar. I remember aurora having this issue when working on the matcher

@IotaBread
Copy link
Member

When matching you'd have to index the previous jar (we don't do this currently) to know if a method changed and shift its parameters accordingly. In enigma we just need to validate and drop if any parameters are invalid.
The method I mentioned in a previous comment already has access to both the method descriptor and the method access, so it'd be easy to verify there, though if we want to add local support (as an option), we need max_locals

@ix0rai
Copy link
Member Author

ix0rai commented Jan 4, 2024

maybe we could do it as an arg you pass to the command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli affects the enigma command-line interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants