From 09c77f47c168b7e4e85ff4eb6e073ed0cfbacc4b Mon Sep 17 00:00:00 2001 From: Yotam Date: Fri, 14 Apr 2023 14:21:52 +0300 Subject: [PATCH] class-factory: Fix toString() for overloaded methods (#272) --- lib/class-factory.js | 4 ++++ test/re/frida/MethodTest.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/class-factory.js b/lib/class-factory.js index 1d71bec..e3d914b 100644 --- a/lib/class-factory.js +++ b/lib/class-factory.js @@ -1409,6 +1409,10 @@ dispatcherPrototype = Object.create(Function.prototype, { return method.apply(receiver, args); } + if (this.methodName === 'toString') { + return ``; + } + throwOverloadError(this.methodName, this.overloads, 'argument types do not match any of:'); } } diff --git a/test/re/frida/MethodTest.java b/test/re/frida/MethodTest.java index 2937192..a95c163 100644 --- a/test/re/frida/MethodTest.java +++ b/test/re/frida/MethodTest.java @@ -506,6 +506,14 @@ public void performNowWorks() { assertEquals("Hello", script.getNextMessage()); } + // Issue #271 + @Test + public void toStringOnOverloadedToString() { + loadScript("const utf16 = Java.use('android.icu.text.UTF16');" + + "send(utf16.toString());"); + assertEquals("", script.getNextMessage()); + } + @Test public void replacementCanAcceptModifiedUTF8StringParameter() { loadScript("var Badger = Java.use('re.frida.Badger');" +