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

Corrupt generic signatures lead to incorrect class super types/interfaces, field types, and method parameter/variable types #409

Open
SpaceWalkerRS opened this issue Jul 24, 2024 · 0 comments · May be fixed by #430
Labels
Priority: Low Low priority Subsystem: Generics Anything concerning how generics are decompiled Type: Bug Something isn't working

Comments

@SpaceWalkerRS
Copy link

Vineflower version

1.10.1

Describe the bug

If generic signatures are present, Vineflower replaces the corresponding types with those in the signatures, without verifying that they are the same.

Additional information

For example, take the following class

import java.util.ArrayList;
import java.util.List;

abstract class Signatures implements List<String> {
	List<String> field = new ArrayList<>();

	void method(List<String> o) {
	}
}

The class Signatures has interface java/util/List and signature Ljava/lang/Object;Ljava/util/List<Ljava/lang/String;>;.
The field field has descriptor Ljava/util/List; and signature Ljava/util/List<Ljava/lang/String;>;.
The method method has descriptor (Ljava/util/List;)V and signature Ljava/util/List<Ljava/lang/String;>;.

Now if we corrupt the class file by changing only the signatures, as follows:
Change the class signature to Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;.
Change the field signature to Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;.
Change the method signature to (Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;)V.

This corrupted class file will decompile to

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

abstract class Signatures implements Map<String, String> {
	Map<String, String> field = new ArrayList();

	void method(Map<String, String> o) {
	}
}

Notice that the class interface, field descriptor, and method descriptor all changed, while those were not modified in the class file at all.

In situations like this Vineflower ought to ignore corrupted signatures rather than corrupting other code with it.

Here's the class files I tested with:
uncorrupted class file
corrupted class file

@SpaceWalkerRS SpaceWalkerRS added the Type: Bug Something isn't working label Jul 24, 2024
@jaskarth jaskarth added Subsystem: Generics Anything concerning how generics are decompiled Priority: Low Low priority labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low Low priority Subsystem: Generics Anything concerning how generics are decompiled Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants