Skip to content

Commit

Permalink
Limit size of strings to 65535 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
piazzesiNiccolo-GS committed Dec 13, 2024
1 parent 430a045 commit bacde1c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/src/main/java/proguard/ProGuard.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import proguard.evaluation.IncompleteClassHierarchyException;
import proguard.logging.Logging;
import proguard.mark.Marker;
import proguard.normalize.StringNormalizer;
import proguard.obfuscate.NameObfuscationReferenceFixer;
import proguard.obfuscate.ObfuscationPreparation;
import proguard.obfuscate.Obfuscator;
Expand Down Expand Up @@ -219,6 +220,7 @@ public void execute() throws Exception
configuration.obfuscate)
{
expandPrimitiveArrayConstants();
normalizeStrings();
}

if (configuration.targetClassVersion != 0)
Expand Down Expand Up @@ -269,6 +271,11 @@ public void execute() throws Exception
}
}

private void normalizeStrings() throws Exception {
passRunner.run(new StringNormalizer(),appView);

}


/**
* Checks the GPL.
Expand Down
22 changes: 22 additions & 0 deletions base/src/main/java/proguard/normalize/StringNormalizer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package proguard.normalize;

import proguard.AppView;
import proguard.classfile.visitor.ParallelAllClassVisitor;
import proguard.pass.Pass;
import proguard.pass.PassId;

/**
* Ensures all strings are at most 65535 bytes in length, when encoded as modified UTF-8.
*
* @see LargeStringSplitter
*/
public class StringNormalizer implements Pass {


@Override
public void execute(AppView appView) throws Exception {
appView.programClassPool.accept(
new ParallelAllClassVisitor(
() -> new LargeStringSplitter(appView.programClassPool, appView.libraryClassPool)));
}
}
7 changes: 7 additions & 0 deletions docs/md/manual/releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

## Version 7.6.2

### Bugfixes

- Prevent `IllegalArgumentException` when strings longer than 65535 bytes are present in the application (#267).

## Version 7.6.1

### Bugfixes
Expand Down

0 comments on commit bacde1c

Please sign in to comment.