Skip to content

Conversation

@thestr4ng3r
Copy link
Member

@thestr4ng3r thestr4ng3r commented Jul 31, 2022

DO NOT SQUASH

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

Despite being a fantastic library, libuv was only ever used for the tcp server for almost 4 years. This fixes the non-libuv tcp server and drops libuv in favor of it. See commit descriptions for details.

Test plan

Warning: if tcp.islocal=false, the following will open complete shell access to 0.0.0.0!
rz -c "Rt 1337", then from another terminal do e.g. echo "?E hello" | nc localhost 1337 and see the command output.
Ctrl+C should also break the Rt command properly.

@thestr4ng3r thestr4ng3r force-pushed the drop-libuv branch 3 times, most recently from 074a964 to d5b9a30 Compare July 31, 2022 09:56
@thestr4ng3r thestr4ng3r marked this pull request as ready for review July 31, 2022 10:35
@thestr4ng3r thestr4ng3r changed the title Drop libuv Rewrite non-libuv tcp server and drop libuv Jul 31, 2022
The non-libuv tcp server implementation had several issues:
* Relied on EINTR or self-connect through global vars for breaking,
  which did not work during recv() for example.
* Never retried on EINTR
* Called recv() only once, thus subject to fragmentation issues

To support breaking otherwise blocking socket calls, RzStopPipe has been
imported from chiaki (I am the sole author so I can relicense).

rz_socket_block_time() was also detected to be doing the exact opposite
than it should on Windows through the tests, and fixed.
libuv was only ever used for the tcp server for almost 4 years. Since
the non-libuv implementation of that is working now, it can be dropped
entirely without sacrificing functionality.
Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resend this from dist-asan-fuzz- branch, please.
@GustavoLCR could you please take a look if everything is fine from the Windows point of view?


uv_tcp_t *client = RZ_NEW(uv_tcp_t);
if (!client) {
RZ_API void rz_core_rtr_cmds(RzCore *core, const char *port) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygen, please

return str;
#else
return NULL;
return NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this indentation intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format enforces it, but it makes no sense imo.

#endif
}; // RzStopPipe

RZ_API RzStopPipe *rz_stop_pipe_new(void) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygen with explanation what exactly RzStopPipe is?

@thestr4ng3r
Copy link
Member Author

Superseded by #2860

@wargio wargio deleted the drop-libuv branch December 7, 2022 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants