Limit size of strings to 65535 bytes

This commit is contained in:
niccolo.piazzesi
2024-12-13 09:55:49 +01:00
parent 430a04502d
commit bacde1cede
3 changed files with 36 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import proguard.configuration.InitialStateInfo;
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;
@@ -219,6 +220,7 @@ public class ProGuard
configuration.obfuscate)
{
expandPrimitiveArrayConstants();
normalizeStrings();
}
if (configuration.targetClassVersion != 0)
@@ -269,6 +271,11 @@ public class ProGuard
}
}
private void normalizeStrings() throws Exception {
passRunner.run(new StringNormalizer(),appView);
}
/**
* Checks the GPL.

View File

@@ -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)));
}
}

View File

@@ -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