Skip to content

Commit

Permalink
Tweak style
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Oct 20, 2024
1 parent 288127a commit ba531c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
43 changes: 19 additions & 24 deletions inject/inject.vala
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ namespace Frida.Inject {
buf[n] = 0;

if (script_runner.terminal_mode == TerminalMode.BINARY) {
var bytes = new Bytes (buf[0:n]);
var bytes = new Bytes (buf[:n]);
script_runner.on_stdin ("", bytes);
} else {
script_runner.on_stdin ((string) buf, null);
Expand Down Expand Up @@ -740,14 +740,13 @@ namespace Frida.Inject {
return false;

var tuple = payload.get_array ();
if (tuple.get_length () < 1)
var tuple_len = tuple.get_length ();
if (tuple_len == 0)
return false;

var first_element = tuple.get_element (0);
if (first_element.get_value_type () != typeof (string))
var type = tuple.get_element (0).get_string ();
if (type == null)
return false;

var type = first_element.get_string ();
switch (type) {
case "frida:stdout":
case "frida:stderr":
Expand All @@ -756,26 +755,21 @@ namespace Frida.Inject {
return false;
}

if (tuple.get_length () > 1) {
var second_element = tuple.get_element (1);

if (second_element.get_value_type () != typeof (string))
if (tuple_len >= 2) {
var str = tuple.get_element (1).get_string ();
if (str == null)
return false;

var str = second_element.get_string ();

if (str != null) {
switch (type) {
case "frida:stdout":
stdout.write (str.data);
stdout.flush ();
break;
case "frida:stderr":
stderr.write (str.data);
break;
default:
return false;
}
switch (type) {
case "frida:stdout":
stdout.write (str.data);
stdout.flush ();
break;
case "frida:stderr":
stderr.write (str.data);
break;
default:
return false;
}
}

Expand All @@ -792,6 +786,7 @@ namespace Frida.Inject {
return false;
}
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/barebone/script.vala
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ namespace Frida {

public void post (string json, Bytes? data) {
var json_val = ctx.make_string (json);
var data_val = ctx.make_array_buffer (data.get_data ());
var data_val = (data != null) ? ctx.make_array_buffer (data.get_data ()) : QuickJS.Null;
invoke_void (dispatch_message_func, { json_val, data_val }, runtime_obj);
ctx.free_value (data_val);
ctx.free_value (json_val);
Expand Down
3 changes: 2 additions & 1 deletion src/host-session-service.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,8 @@ namespace Frida {
protected virtual void on_event (string type, Json.Array event) {
}

protected async Json.Node call (string method, Json.Node[] args, Bytes? data, Cancellable? cancellable) throws Error, IOError {
protected async Json.Node call (string method, Json.Node[] args, Bytes? data, Cancellable? cancellable)
throws Error, IOError {
yield ensure_loaded (cancellable);

return yield rpc_client.call (method, args, data, cancellable);
Expand Down

0 comments on commit ba531c9

Please sign in to comment.