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

ClassLoader fails to load java classes with null byte naming #50

Closed
Moudoux opened this issue Jul 25, 2020 · 2 comments
Closed

ClassLoader fails to load java classes with null byte naming #50

Moudoux opened this issue Jul 25, 2020 · 2 comments

Comments

@Moudoux
Copy link

Moudoux commented Jul 25, 2020

As the title says, loading a mod jar which has null characters in the file name will make Minecraft crash when using this (Latest Forge 1.16.1), the normal Minecraft loader does not do this, nor does other loaders like Fabric.

The main error is: Error: java.nio.file.InvalidPathException: Path: nul character not allowed: followed by the path itself.

The whole stacktrace:

java.nio.file.InvalidPathException: Path: nul character not allowed: <null character>/<the path to my class>
    at com.sun.nio.zipfs.ZipPath.normalize(ZipPath.java:448)
    at com.sun.nio.zipfs.ZipPath.<init>(ZipPath.java:76)
    at com.sun.nio.zipfs.ZipPath.<init>(ZipPath.java:67)
    at com.sun.nio.zipfs.ZipFileSystem.getPath(ZipFileSystem.java:186)
    at com.sun.nio.zipfs.ZipFileSystem.getPath(ZipFileSystem.java:80)
    at net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer$MinecraftLocator.findPathJar(ModDiscoverer.java:200)
    at net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer$MinecraftLocator.findPath(ModDiscoverer.java:187)
    at net.minecraftforge.fml.loading.moddiscovery.ModFile.findResource(ModFile.java:181)
    at net.minecraftforge.fml.loading.LoadingModList.findURLForResource(LoadingModList.java:126)
    at net.minecraftforge.fml.loading.FMLCommonLaunchHandler.lambda$getClassLoaderLocatorFunction$5(FMLCommonLaunchHandler.java:132)
    at net.minecraftforge.fml.loading.FMLCommonLaunchHandler$$Lambda$409/664839586.apply(Unknown Source)
    at cpw.mods.modlauncher.TransformationServicesHandler.lambda$alternate$1(TransformationServicesHandler.java:52)
    at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$414/651235118.apply(Unknown Source)
    at cpw.mods.modlauncher.TransformationServicesHandler.lambda$alternate$1(TransformationServicesHandler.java:52)
    at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$414/651235118.apply(Unknown Source)
    at cpw.mods.modlauncher.TransformingClassLoader.lambda$alternate$10(TransformingClassLoader.java:85)
    at cpw.mods.modlauncher.TransformingClassLoader$$Lambda$420/295055909.apply(Unknown Source)
    at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:218)
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:126)
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:96)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
    at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:814)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at <my class calling a new MyClass()>```
 
The null character is a common in obfuscation programs, and forge with modlauncher cannot load it.
@pau101
Copy link

pau101 commented Jul 26, 2020

Such "obfuscation" techniques as this are not expected to work in every java environment, Mod Launcher happens to be one which will not accept this particular hack. I would not expect to find any support for this sort behavior of using exploits geared specifically to target decompilation tools which can be trivially worked around for anyone dedicated to reverse engineering your code.

@cpw
Copy link
Member

cpw commented Jul 26, 2020

Not an issue in my books. You're clearly trying to use some kind of obfuscation hack, to pack your jar with dodgy code. Don't do that? What's so special about your code that you need to hide it behind NUL characters.

Do note that the error comes from NIO zip handling in java, which I cannot fix. Maybe go ask them to support your crazy naming scheme instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants