From 61cb054e164b615ef0039f3dd877f88767c38725 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 8 Nov 2023 18:59:12 +0100 Subject: [PATCH] Handle non-message arguments in fallback script --- android/android-certificate-unpinning-fallback.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/android-certificate-unpinning-fallback.js b/android/android-certificate-unpinning-fallback.js index e329453..6896cb6 100644 --- a/android/android-certificate-unpinning-fallback.js +++ b/android/android-certificate-unpinning-fallback.js @@ -108,10 +108,14 @@ Java.perform(function () { }; const buildUnhandledErrorPatcher = (errorClassName, originalConstructor) => { - return function (errorMessage) { + return function (errorArg) { try { console.log('\n !!! --- Unexpected TLS failure --- !!!'); + // This may be a message, or an cause, or plausibly maybe other types? But + // stringifying gives something consistently message-shaped, so that'll do. + const errorMessage = errorArg?.toString() ?? ''; + // Parse the stack trace to work out who threw this error: const stackTrace = Java.use('java.lang.Thread').currentThread().getStackTrace(); const exceptionStackIndex = stackTrace.findIndex(stack =>