From a4120e09c5d279cf18241ad41fb41398659e1d3b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 01:44:27 +0000 Subject: [PATCH 1/4] Treat READ_EXTERNAL_STORAGE as held by apps that declare WRITE_EXTERNAL_STORAGE Android's implicit permission split grants READ to such apps. SKYBOX declares only WRITE and was refused READ, so it reported no permission to read files. Co-Authored-By: Claude Sonnet 5.5 --- .../framework/android/content/pm/PackageManager.java | 9 ++++++++- tests/java/FrameworkTest.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/runtime/java/framework/android/content/pm/PackageManager.java b/src/runtime/java/framework/android/content/pm/PackageManager.java index 30be10a..b0cbc59 100644 --- a/src/runtime/java/framework/android/content/pm/PackageManager.java +++ b/src/runtime/java/framework/android/content/pm/PackageManager.java @@ -315,7 +315,14 @@ public boolean hasSystemFeature(String name, int version) { return false; } public int checkPermission(String permission, String pkg) { - if (!model.info.packageName.equals(pkg) || !model.permissions.contains(permission)) return -1; + if (!model.info.packageName.equals(pkg)) return -1; + // Android's implicit permission split: an app that declares WRITE_EXTERNAL_STORAGE is also + // treated as holding READ_EXTERNAL_STORAGE, so one that checks (or requests) READ alone, as + // media players do before listing a folder, is not refused for a permission it never needed + // to declare. + boolean impliedRead = "android.permission.READ_EXTERNAL_STORAGE".equals(permission) + && model.permissions.contains("android.permission.WRITE_EXTERNAL_STORAGE"); + if (!impliedRead && !model.permissions.contains(permission)) return -1; // Runtime permissions the Quest permission dialog grants (RECORD_AUDIO). if (com.venture.runtime.RuntimePermissions.granted(model, permission)) return 0; return java.util.Set diff --git a/tests/java/FrameworkTest.java b/tests/java/FrameworkTest.java index b00672a..b410872 100644 --- a/tests/java/FrameworkTest.java +++ b/tests/java/FrameworkTest.java @@ -2194,6 +2194,16 @@ public void onCapabilitiesChanged(android.net.Network network, android.net.Netwo && micPackages.checkPermission("android.permission.RECORD_AUDIO", "other.package") == -1 && micPackages.checkPermission("android.permission.CAMERA", "test.mic") == -1, "the permission dialog grants the microphone, not the camera"); + var storageManifest = manifestNode("manifest", "package", "test.storage"); + storageManifest.children.add(manifestNode("uses-permission", "name", "android.permission.WRITE_EXTERNAL_STORAGE")); + storageManifest.children.add(manifestNode("application")); + var storagePackages = new android.content.pm.PackageManager(new PackageModel(storageManifest)); + check(storagePackages.checkPermission("android.permission.READ_EXTERNAL_STORAGE", "test.storage") == 0 + && storagePackages.checkPermission("android.permission.WRITE_EXTERNAL_STORAGE", "test.storage") == 0 + && storagePackages.checkPermission("android.permission.READ_EXTERNAL_STORAGE", "other.package") == -1, + "declaring WRITE_EXTERNAL_STORAGE also grants READ_EXTERNAL_STORAGE"); + check(new android.content.pm.PackageManager(micModel).checkPermission("android.permission.READ_EXTERNAL_STORAGE", "test.mic") == -1, + "READ_EXTERNAL_STORAGE is not implied without WRITE_EXTERNAL_STORAGE"); var undeclaredMic = new PackageModel(manifest); undeclaredMic.info.applicationInfo.targetSdkVersion = 32; com.venture.runtime.RuntimePermissions.request(undeclaredMic, new String[] {"android.permission.RECORD_AUDIO"}); From b1ba715972ca1447bb1acad32d9b82a93fffa98e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 06:16:47 +0000 Subject: [PATCH 2/4] Show how a non-PrivateBin upload answer begins Co-Authored-By: Claude Sonnet 5.5 --- src/common/privatebin.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/privatebin.cpp b/src/common/privatebin.cpp index daef6c1..7a3733e 100644 --- a/src/common/privatebin.cpp +++ b/src/common/privatebin.cpp @@ -183,8 +183,17 @@ std::string paste(std::string_view server, std::string_view text, std::string_vi if (reply_http.status != 200 || !reply.is_object() || reply.value("status", 1) != 0 || !reply.contains("id") || !reply["id"].is_string() || !valid_id(reply["id"].get())) { std::string why = reason(reply); - throw std::runtime_error(why.empty() ? "The upload service answered " + std::to_string(reply_http.status) + "." - : "The upload service refused it: " + why); + if (!why.empty()) throw std::runtime_error("The upload service refused it: " + why); + // Not a PrivateBin answer (a proxy or firewall in front of it): show how it began, in one line. + std::string excerpt; + for (char c : reply_http.body) { + if (excerpt.size() >= 120) break; + if (c == '\r' || c == '\n' || c == '\t') c = ' '; + if (static_cast(c) >= 0x20 && static_cast(c) < 0x7f && !(c == ' ' && (excerpt.empty() || excerpt.back() == ' '))) + excerpt += c; + } + throw std::runtime_error("The upload service answered " + std::to_string(reply_http.status) + + (excerpt.empty() ? "." : ": " + excerpt)); } return std::string(server) + "/?" + reply["id"].get() + "#" + sealed.fragment; } From 589212d5f6c47fc1bab853b549fb4272ecf3e848 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 06:17:12 +0000 Subject: [PATCH 3/4] Ship jdk.charsets in the runtime JRE SKYBOX's native startup calls String.getBytes("GB2312"), which the base-only JRE refuses, so the game aborted a few seconds after launch. Co-Authored-By: Claude Sonnet 5.5 --- tests/jre_modules_test.py | 4 ++++ tools/dex/make_jre.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/jre_modules_test.py b/tests/jre_modules_test.py index ae0768d..d93ee99 100644 --- a/tests/jre_modules_test.py +++ b/tests/jre_modules_test.py @@ -36,6 +36,10 @@ def test_tls_and_ec_crypto_are_in_the_jre(self): # Android's EC KeyPairGenerator, KeyAgreement and Signature algorithms need it as well. self.assertIn("jdk.crypto.ec", modules()) + def test_extended_charsets_are_in_the_jre(self): + # Android has GB2312, Big5, Shift_JIS ... built in; SKYBOX's startup asks for GB2312 by name. + self.assertIn("jdk.charsets", modules()) + if __name__ == "__main__": sys.exit(unittest.main()) diff --git a/tools/dex/make_jre.py b/tools/dex/make_jre.py index 0255d2a..e24f6c0 100644 --- a/tools/dex/make_jre.py +++ b/tools/dex/make_jre.py @@ -14,8 +14,11 @@ # JSSE offers no ECDHE group, no ECDHE suite and no ECDSA signature, so Google, Firebase and most # CDN servers answer every HTTPS ClientHello with handshake_failure (issue 168). Dev runs use the # full JDK, so only the shipped JRE showed it. +# jdk.charsets: the extended charsets (GB2312, GBK, Big5, Shift_JIS, EUC-KR, ...). Android always has +# them, and apps ask for them by name: SKYBOX's native startup calls String.getBytes("GB2312") and +# died with UnsupportedEncodingException on the base-only JRE. # No java.sql or java.net.http. -MODULES = "java.base,java.logging,java.xml,java.desktop,jdk.crypto.ec,jdk.unsupported" +MODULES = "java.base,java.logging,java.xml,java.desktop,jdk.charsets,jdk.crypto.ec,jdk.unsupported" def main(): From b3d607bfdf8ffbe0bcc117756c9177ebf8b67974 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 22:18:59 +0000 Subject: [PATCH 4/4] Fix string escapes in the PrivateBin test Co-Authored-By: Claude Sonnet 5.5 --- tests/privatebin_test.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/privatebin_test.cpp b/tests/privatebin_test.cpp index 5cda52a..6012e84 100644 --- a/tests/privatebin_test.cpp +++ b/tests/privatebin_test.cpp @@ -35,14 +35,12 @@ TEST_CASE("PrivateBin encodings and paste round trip") { CHECK(privatebin::base64(crypto::Bytes{'f', 'o', 'o'}) == "Zm9v"); CHECK(privatebin::base58(crypto::Bytes{0, 0, 1}) == "112"); CHECK(privatebin::base58(crypto::Bytes{'h', 'e', 'l', 'l', 'o'}) == "Cn8eVZg"); - std::string text = "report café "quoted" \ tab -"; - for (int i = 0; i < 2000; ++i) text += "12345.678 I [launch] repeated log line " + std::to_string(i) + " -"; + std::string text = "report caf\xC3\xA9 \"quoted\" \\ tab\t\n"; + for (int i = 0; i < 2000; ++i) text += "12345.678 I [launch] repeated log line " + std::to_string(i) + "\n"; auto enc = privatebin::encrypt(text, "1month"); CHECK(privatebin::decrypt(enc.body, enc.fragment) == text); auto other = privatebin::encrypt(text, "1month"); CHECK_THROWS(privatebin::decrypt(enc.body, other.fragment)); - auto odd = privatebin::encrypt("bad byte ÿþ here", "1day"); + auto odd = privatebin::encrypt("bad byte \xFF\xFE here", "1day"); CHECK(privatebin::decrypt(odd.body, odd.fragment).starts_with("bad byte")); }