summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/trans.c17
-rw-r--r--rdp/rdp_rdp.c3
-rw-r--r--rdp/rdp_tcp.c3
-rw-r--r--sesman/sesman.c10
-rw-r--r--sesman/session.c30
-rw-r--r--sesman/tools/sesadmin.c6
-rw-r--r--sesman/tools/sesrun.c3
-rw-r--r--sesman/tools/sestest.c3
-rw-r--r--vnc/vnc.c7
-rw-r--r--xrdp/xrdp_listen.c3
-rw-r--r--xrdp/xrdp_login_wnd.c5
-rw-r--r--xrdp/xrdp_mm.c4
-rw-r--r--xup/xup.c5
13 files changed, 82 insertions, 17 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)
diff --git a/rdp/rdp_rdp.c b/rdp/rdp_rdp.c
index 70155c60..9ce63664 100644
--- a/rdp/rdp_rdp.c
+++ b/rdp/rdp_rdp.c
@@ -1170,6 +1170,9 @@ rdp_rec_check_file(struct rdp_rdp *self)
}
self->rec_fd = g_file_open(file_name);
+ if (self->rec_fd < 0)
+ return 1;
+
make_stream(s);
init_stream(s, 8192);
out_uint8a(s, "XRDPREC1", 8);
diff --git a/rdp/rdp_tcp.c b/rdp/rdp_tcp.c
index a919259e..f0a76d7d 100644
--- a/rdp/rdp_tcp.c
+++ b/rdp/rdp_tcp.c
@@ -157,7 +157,10 @@ int APP_CC
rdp_tcp_connect(struct rdp_tcp *self, char *ip, char *port)
{
DEBUG((" in rdp_tcp_connect ip %s port %s", ip, port));
+
self->sck = g_tcp_socket();
+ if (self->sck < 0)
+ return 1;
if (g_tcp_connect(self->sck, ip, port) == 0)
{
diff --git a/sesman/sesman.c b/sesman/sesman.c
index 964bc740..1c620210 100644
--- a/sesman/sesman.c
+++ b/sesman/sesman.c
@@ -54,7 +54,14 @@ sesman_main_loop(void)
/*main program loop*/
log_message(LOG_LEVEL_INFO, "listening...");
+
g_sck = g_tcp_socket();
+ if (g_sck < 0)
+ {
+ log_message(LOG_LEVEL_ERROR, "error opening socket, g_tcp_socket() failed...");
+ return 1;
+ }
+
g_tcp_set_non_blocking(g_sck);
error = scp_tcp_bind(g_sck, g_cfg->listen_address, g_cfg->listen_port);
@@ -132,7 +139,8 @@ sesman_main_loop(void)
g_get_errno(), g_get_strerror());
}
- g_tcp_close(g_sck);
+ if (g_sck != -1)
+ g_tcp_close(g_sck);
}
/******************************************************************************/
diff --git a/sesman/session.c b/sesman/session.c
index 130ca26c..fb7193a1 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -203,26 +203,32 @@ x_server_running_check_ports(int display)
if (!x_running) /* check 59xx */
{
- sck = g_tcp_socket();
- g_sprintf(text, "59%2.2d", display);
- x_running = g_tcp_bind(sck, text);
- g_tcp_close(sck);
+ if ((sck = g_tcp_socket()) != -1)
+ {
+ g_sprintf(text, "59%2.2d", display);
+ x_running = g_tcp_bind(sck, text);
+ g_tcp_close(sck);
+ }
}
if (!x_running) /* check 60xx */
{
- sck = g_tcp_socket();
- g_sprintf(text, "60%2.2d", display);
- x_running = g_tcp_bind(sck, text);
- g_tcp_close(sck);
+ if ((sck = g_tcp_socket()) != -1)
+ {
+ g_sprintf(text, "60%2.2d", display);
+ x_running = g_tcp_bind(sck, text);
+ g_tcp_close(sck);
+ }
}
if (!x_running) /* check 62xx */
{
- sck = g_tcp_socket();
- g_sprintf(text, "62%2.2d", display);
- x_running = g_tcp_bind(sck, text);
- g_tcp_close(sck);
+ if ((sck = g_tcp_socket()) != -1)
+ {
+ g_sprintf(text, "62%2.2d", display);
+ x_running = g_tcp_bind(sck, text);
+ g_tcp_close(sck);
+ }
}
return x_running;
diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c
index 979a22f9..32789c6d 100644
--- a/sesman/tools/sesadmin.c
+++ b/sesman/tools/sesadmin.c
@@ -107,6 +107,12 @@ int main(int argc, char **argv)
scp_init(&logging);
sock = g_tcp_socket();
+ if (sock < 0)
+ {
+ LOG_DBG("Socket open error, g_tcp_socket() failed\n");
+ return 1;
+ }
+
s = scp_session_create();
c = scp_connection_create(sock);
diff --git a/sesman/tools/sesrun.c b/sesman/tools/sesrun.c
index 7ac10102..a9181583 100644
--- a/sesman/tools/sesrun.c
+++ b/sesman/tools/sesrun.c
@@ -75,7 +75,10 @@ main(int argc, char **argv)
init_stream(in_s, 8192);
make_stream(out_s);
init_stream(out_s, 8192);
+
sck = g_tcp_socket();
+ if (sck < 0)
+ return 1;
if (g_tcp_connect(sck, argv[1], g_cfg.listen_port) == 0)
{
diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c
index f2823eb6..d42b31de 100644
--- a/sesman/tools/sestest.c
+++ b/sesman/tools/sestest.c
@@ -38,6 +38,9 @@ int main(int argc, char **argv)
scp_init(&log);
sock = g_tcp_socket();
+ if (sock < 0)
+ return 1;
+
s = scp_session_create();
c = scp_connection_create(sock);
diff --git a/vnc/vnc.c b/vnc/vnc.c
index 979033e5..780c3629 100644
--- a/vnc/vnc.c
+++ b/vnc/vnc.c
@@ -967,7 +967,14 @@ lib_mod_connect(struct vnc *v)
make_stream(s);
g_sprintf(con_port, "%s", v->port);
make_stream(pixel_format);
+
v->sck = g_tcp_socket();
+ if (v->sck < 0)
+ {
+ v->server_msg(v, "VNC error: socket create error, g_tcp_socket() failed", 0);
+ return 1;
+ }
+
v->sck_obj = g_create_wait_obj_from_socket(v->sck, 0);
v->sck_closed = 0;
g_sprintf(text, "VNC connecting to %s %s", v->ip, con_port);
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
index fb4d9aec..b2b19ca2 100644
--- a/xrdp/xrdp_listen.c
+++ b/xrdp/xrdp_listen.c
@@ -244,7 +244,8 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
list_delete(values);
}
- g_file_close(fd);
+ if (fd != -1)
+ g_file_close(fd);
/* startup_param overrides */
if (startup_param->port[0] != 0)
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
index 5b49d44e..b519f913 100644
--- a/xrdp/xrdp_login_wnd.c
+++ b/xrdp/xrdp_login_wnd.c
@@ -459,9 +459,10 @@ xrdp_wm_login_fill_in_combo(struct xrdp_wm *self, struct xrdp_bitmap *b)
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
fd = g_file_open(cfg_file); /* xrdp.ini */
- if (fd < 1)
+ if (fd < 0)
{
log_message(LOG_LEVEL_ERROR, "Could not read xrdp ini file %s", cfg_file);
+ return 1;
}
file_read_sections(fd, sections);
@@ -956,7 +957,7 @@ load_xrdp_config(struct xrdp_config *config, int bpp)
g_writeln("ls_width: %d", globals->ls_width);
g_writeln("ls_height: %d", globals->ls_height);
g_writeln("ls_bg_color: %x", globals->ls_bg_color);
- g_writeln("ls_title: %s", globals->ls_title);
+ g_writeln("ls_title: %s", globals->ls_title);
g_writeln("ls_logo_filename: %s", globals->ls_logo_filename);
g_writeln("ls_logo_x_pos: %d", globals->ls_logo_x_pos);
g_writeln("ls_logo_y_pos: %d", globals->ls_logo_y_pos);
diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c
index 2bdd821d..66e9d4c2 100644
--- a/xrdp/xrdp_mm.c
+++ b/xrdp/xrdp_mm.c
@@ -1309,7 +1309,9 @@ xrdp_mm_get_sesman_port(char *port, int port_bytes)
list_delete(values);
}
- g_file_close(fd);
+ if (fd != -1)
+ g_file_close(fd);
+
return 0;
}
diff --git a/xup/xup.c b/xup/xup.c
index 294500be..4964692a 100644
--- a/xup/xup.c
+++ b/xup/xup.c
@@ -212,10 +212,15 @@ lib_mod_connect(struct mod *mod)
if (use_uds)
{
mod->sck = g_tcp_local_socket();
+ if (mod->sck < 0)
+ return 1;
}
else
{
mod->sck = g_tcp_socket();
+ if (mod->sck < 0)
+ return 1;
+
g_tcp_set_non_blocking(mod->sck);
g_tcp_set_no_delay(mod->sck);
}