diff options
author | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2014-07-26 13:33:23 -0700 |
---|---|---|
committer | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2014-07-26 13:33:23 -0700 |
commit | 27055d5762d23ae3996e7e41ef45ef6454fa2d65 (patch) | |
tree | b45025733988961e08bde0c7e495f73c939a9937 /common | |
parent | fde7be5151f7db096610cb59ca964e22e6af79fb (diff) | |
download | xrdp-proprietary-27055d5762d23ae3996e7e41ef45ef6454fa2d65.tar.gz xrdp-proprietary-27055d5762d23ae3996e7e41ef45ef6454fa2d65.zip |
coverity: improper use of negative value
Diffstat (limited to 'common')
-rw-r--r-- | common/trans.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/trans.c b/common/trans.c index 6fd5a9d8..aa75e5f1 100644 --- a/common/trans.c +++ b/common/trans.c @@ -501,12 +501,18 @@ trans_connect(struct trans *self, const char *server, const char *port, if (self->mode == TRANS_MODE_TCP) /* tcp */ { self->sck = g_tcp_socket(); + if (self->sck < 0) + return 1; + g_tcp_set_non_blocking(self->sck); error = g_tcp_connect(self->sck, server, port); } else if (self->mode == TRANS_MODE_UNIX) /* unix socket */ { self->sck = g_tcp_local_socket(); + if (self->sck < 0) + return 1; + g_tcp_set_non_blocking(self->sck); error = g_tcp_local_connect(self->sck, port); } @@ -537,6 +543,10 @@ trans_connect(struct trans *self, const char *server, const char *port, } /*****************************************************************************/ + +/** + * @return 0 on success, 1 on failure + */ int APP_CC trans_listen_address(struct trans *self, char *port, const char *address) { @@ -548,6 +558,9 @@ trans_listen_address(struct trans *self, char *port, const char *address) if (self->mode == TRANS_MODE_TCP) /* tcp */ { self->sck = g_tcp_socket(); + if (self->sck < 0) + return 1; + g_tcp_set_non_blocking(self->sck); if (g_tcp_bind_address(self->sck, port, address) == 0) @@ -565,7 +578,11 @@ trans_listen_address(struct trans *self, char *port, const char *address) g_free(self->listen_filename); self->listen_filename = 0; g_file_delete(port); + self->sck = g_tcp_local_socket(); + if (self->sck < 0) + return 1; + g_tcp_set_non_blocking(self->sck); if (g_tcp_local_bind(self->sck, port) == 0) |