Upstreamify profiles (#2472)

* Extended MCOptionUtils to support list values

* Mitigation for the Apache Log4j RCE in 1.8.x-1.18

Related issue: #2378

* Update JREUtils.java

* Completely fix Log4J RCE (1.7-1.16.5) (not yet tested)
#2378

* fix moment

* Fix a NullPointerException when launching ≤ 1.6.4

* Updated virgl vtest (arm64 only)

Experimental changes:
- HACK: explicitly set location for fsout_c0/1. this might not work, not tested
- Fix empty screen on OF + shader: caused by target fb/texture changed

* Trigger a texture creation, which then set VIRGL_TEXTURE_ID

* Replace sprintf with asprintf for auto allocation

* Update egl_bridge.c

* Updated vtest lib: fixes flipped screen

* CI: Update gl4es

* Updated vtest arm64: fixes black screen on <1.13(?)

Co-authored-by: SerpentSpirale <mathiasboulay@free.fr>
Co-authored-by: Duy Tran Khanh <40482367+khanhduytran0@users.noreply.github.com>
Co-authored-by: khanhduytran0 <khanhduytran0@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@users.noreply.github.com>
This commit is contained in:
ArtDev 2021-12-28 11:19:57 +03:00 committed by GitHub
parent 9fc4d5dc82
commit 85889338c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 64 additions and 14 deletions

View File

@ -1,10 +1,8 @@
package net.kdt.pojavlaunch;
import androidx.annotation.Keep;
import java.util.Map;
import net.kdt.pojavlaunch.value.*;
import java.util.*;
import net.kdt.pojavlaunch.value.*;
@Keep
public class JMinecraftVersionList {
@ -16,18 +14,23 @@ public class JMinecraftVersionList {
public Version[] versions;
@Keep
public static class Version {
public static class FileProperties {
public String id, sha1, url;
public long size;
}
@Keep
public static class Version extends FileProperties {
// Since 1.13, so it's one of ways to check
public Arguments arguments;
public AssetIndex assetIndex;
public String assets;
public Map<String, MinecraftClientInfo> downloads;
public String id;
public String inheritsFrom;
public JavaVersionInfo javaVersion;
public DependentLibrary[] libraries;
public LoggingConfig logging;
public String mainClass;
public String minecraftArguments;
public int minimumLauncherVersion;
@ -35,15 +38,23 @@ public class JMinecraftVersionList {
public String releaseTime;
public String time;
public String type;
public String url;
public String sha1;
}
@Keep
public static class JavaVersionInfo {
public String component;
public int majorVersion;
}
@Keep
public static class LoggingConfig {
public LoggingClientConfig client;
@Keep
public static class LoggingClientConfig {
public String argument;
public FileProperties file;
public String type;
}
}
// Since 1.13
@Keep
public static class Arguments {
@ -66,9 +77,8 @@ public class JMinecraftVersionList {
}
}
@Keep
public static class AssetIndex {
public String id, sha1, url;
public long size, totalSize;
public static class AssetIndex extends FileProperties {
public long totalSize;
}
}

View File

@ -151,6 +151,9 @@ public final class Tools {
}
*/
if (versionInfo.logging != null) {
javaArgList.add("-Dlog4j.configurationFile=" + Tools.DIR_GAME_NEW + "/" + versionInfo.logging.client.file.id);
}
javaArgList.add("-cp");
javaArgList.add(getLWJGL3ClassPath() + ":" + launchClassPath);

View File

@ -130,6 +130,36 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
File outLib;
// Patch the Log4J RCE (CVE-2021-44228)
if (verInfo.logging != null) {
outLib = new File(Tools.DIR_GAME_NEW, verInfo.logging.client.file.id);
if (outLib.exists()) {
if(LauncherPreferences.PREF_CHECK_LIBRARY_SHA) {
if(!Tools.compareSHA1(outLib,verInfo.logging.client.file.sha1)) {
outLib.delete();
publishProgress("0", mActivity.getString(R.string.dl_library_sha_fail,verInfo.logging.client.file.id));
}else{
publishProgress("0", mActivity.getString(R.string.dl_library_sha_pass,verInfo.logging.client.file.id));
}
} else if (outLib.length() != verInfo.logging.client.file.size) {
// force updating anyways
outLib.delete();
}
}
if (!outLib.exists()) {
publishProgress("0", mActivity.getString(R.string.mcl_launch_downloading, verInfo.logging.client.file.id));
Tools.downloadFileMonitored(
verInfo.logging.client.file.url,
outLib.getAbsolutePath(),
new Tools.DownloaderFeedback() {
@Override
public void updateProgress(int curr, int max) {
publishDownloadProgress(verInfo.logging.client.file.id, curr, max);
}
}
);
}
}
setMax(verInfo.libraries.length);
zeroProgress();

View File

@ -604,6 +604,7 @@ GLubyte* (*glGetString_p) (GLenum name);
void (*glFinish_p) (void);
void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (*glClear_p) (GLbitfield mask);
void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);
/*EGL functions */
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
@ -667,16 +668,16 @@ void pojavTerminate() {
JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, jclass clazz, jobject surface) {
potatoBridge.androidWindow = ANativeWindow_fromSurface(env, surface);
char *ptrStr = malloc(sizeof(long));
sprintf(ptrStr, "%ld", (long) potatoBridge.androidWindow);
char *ptrStr;
asprintf(&ptrStr, "%ld", (long) potatoBridge.androidWindow);
setenv("POJAV_WINDOW_PTR", ptrStr, 1);
free(ptrStr);
}
void* pojavGetCurrentContext() {
switch (config_renderer) {
case RENDERER_GL4ES:
return (void *)eglGetCurrentContext_p();
case RENDERER_VIRGL:
case RENDERER_VK_ZINK:
return (void *)OSMesaGetCurrentContext_p();
@ -716,6 +717,7 @@ void dlsym_OSMesa(void* dl_handle) {
glClearColor_p = dlsym(dl_handle, "glClearColor");
glClear_p = dlsym(dl_handle,"glClear");
glFinish_p = dlsym(dl_handle,"glFinish");
glReadPixels_p = dlsym(dl_handle,"glReadPixels");
}
bool loadSymbols() {
@ -1040,6 +1042,11 @@ void pojavMakeCurrent(void* window) {
printf("OSMDroid: renderer: %s\n",glGetString_p(GL_RENDERER));
glClear_p(GL_COLOR_BUFFER_BIT);
glClearColor_p(0.4f, 0.4f, 0.4f, 1.0f);
// Trigger a texture creation, which then set VIRGL_TEXTURE_ID
int pixelsArr[4];
glReadPixels_p(0, 0, 1, 1, GL_RGB, GL_INT, &pixelsArr);
pojavSwapBuffers();
return;
}