From bb0276e272f64da2209ea5da78a108c8961bc210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Mon, 1 Jun 2015 01:12:31 +0200 Subject: [PATCH] Fix the byte array sniffing to avoid false positives --- src/frida/repl.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/frida/repl.py b/src/frida/repl.py index 102965d..a782aaa 100644 --- a/src/frida/repl.py +++ b/src/frida/repl.py @@ -358,11 +358,15 @@ WARNING: Unable to find package 'gnureadline' needed for tab completion; } function isByteArray(v) { - if (!v || !v.hasOwnProperty('length')) + if (!v || typeof v !== 'object' || typeof v.length !== 'number' || v.length < 1) return false; - return Array.prototype.every.call(v, function (e) { - return typeof e === 'number'; - }); + if (v instanceof Array) // Object returned by Memory.readByteArray() isn't an Array + return false; + for (var i = 0; i !== v.length; i++) { + if (typeof v[i] !== 'number') + return false; + } + return true; } const onStanza = function (stanza) {