Skip to content

Instantly share code, notes, and snippets.

@adsr
Created June 2, 2015 23:10
Show Gist options
  • Select an option

  • Save adsr/526efbd461e296b2a74e to your computer and use it in GitHub Desktop.

Select an option

Save adsr/526efbd461e296b2a74e to your computer and use it in GitHub Desktop.
Index: ncat_listen.c
===================================================================
--- ncat_listen.c (revision 34570)
+++ ncat_listen.c (working copy)
@@ -836,7 +836,7 @@
}
FD_SET(socket_n, &read_fds);
- FD_SET(STDIN_FILENO, &read_fds);
+ if (!o.recvonly) FD_SET(STDIN_FILENO, &read_fds);
fdmax = socket_n;
/* stdin -> socket and socket -> stdout */
@@ -866,18 +866,16 @@
}
if (o.crlf)
fix_line_endings((char *) buf, &nbytes, &tempbuf, &crlf_state);
- if (!o.recvonly) {
- if (tempbuf != NULL)
- n = send(socket_n, tempbuf, nbytes, 0);
- else
- n = send(socket_n, buf, nbytes, 0);
- if (n < nbytes) {
- loguser("%s.\n", socket_strerror(socket_errno()));
- close(socket_n);
- return 1;
- }
- ncat_log_send(buf, nbytes);
+ if (tempbuf != NULL)
+ n = send(socket_n, tempbuf, nbytes, 0);
+ else
+ n = send(socket_n, buf, nbytes, 0);
+ if (n < nbytes) {
+ loguser("%s.\n", socket_strerror(socket_errno()));
+ close(socket_n);
+ return 1;
}
+ ncat_log_send(buf, nbytes);
if (tempbuf != NULL) {
free(tempbuf);
tempbuf = NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment