coverity: improper use of negative value
This commit is contained in:
parent
fde7be5151
commit
27055d5762
@ -501,12 +501,18 @@ trans_connect(struct trans *self, const char *server, const char *port,
|
|||||||
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
||||||
{
|
{
|
||||||
self->sck = g_tcp_socket();
|
self->sck = g_tcp_socket();
|
||||||
|
if (self->sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
g_tcp_set_non_blocking(self->sck);
|
g_tcp_set_non_blocking(self->sck);
|
||||||
error = g_tcp_connect(self->sck, server, port);
|
error = g_tcp_connect(self->sck, server, port);
|
||||||
}
|
}
|
||||||
else if (self->mode == TRANS_MODE_UNIX) /* unix socket */
|
else if (self->mode == TRANS_MODE_UNIX) /* unix socket */
|
||||||
{
|
{
|
||||||
self->sck = g_tcp_local_socket();
|
self->sck = g_tcp_local_socket();
|
||||||
|
if (self->sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
g_tcp_set_non_blocking(self->sck);
|
g_tcp_set_non_blocking(self->sck);
|
||||||
error = g_tcp_local_connect(self->sck, port);
|
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
|
int APP_CC
|
||||||
trans_listen_address(struct trans *self, char *port, const char *address)
|
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 */
|
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
||||||
{
|
{
|
||||||
self->sck = g_tcp_socket();
|
self->sck = g_tcp_socket();
|
||||||
|
if (self->sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
g_tcp_set_non_blocking(self->sck);
|
g_tcp_set_non_blocking(self->sck);
|
||||||
|
|
||||||
if (g_tcp_bind_address(self->sck, port, address) == 0)
|
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);
|
g_free(self->listen_filename);
|
||||||
self->listen_filename = 0;
|
self->listen_filename = 0;
|
||||||
g_file_delete(port);
|
g_file_delete(port);
|
||||||
|
|
||||||
self->sck = g_tcp_local_socket();
|
self->sck = g_tcp_local_socket();
|
||||||
|
if (self->sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
g_tcp_set_non_blocking(self->sck);
|
g_tcp_set_non_blocking(self->sck);
|
||||||
|
|
||||||
if (g_tcp_local_bind(self->sck, port) == 0)
|
if (g_tcp_local_bind(self->sck, port) == 0)
|
||||||
|
@ -1170,6 +1170,9 @@ rdp_rec_check_file(struct rdp_rdp *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
self->rec_fd = g_file_open(file_name);
|
self->rec_fd = g_file_open(file_name);
|
||||||
|
if (self->rec_fd < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
make_stream(s);
|
make_stream(s);
|
||||||
init_stream(s, 8192);
|
init_stream(s, 8192);
|
||||||
out_uint8a(s, "XRDPREC1", 8);
|
out_uint8a(s, "XRDPREC1", 8);
|
||||||
|
@ -157,7 +157,10 @@ int APP_CC
|
|||||||
rdp_tcp_connect(struct rdp_tcp *self, char *ip, char *port)
|
rdp_tcp_connect(struct rdp_tcp *self, char *ip, char *port)
|
||||||
{
|
{
|
||||||
DEBUG((" in rdp_tcp_connect ip %s port %s", ip, port));
|
DEBUG((" in rdp_tcp_connect ip %s port %s", ip, port));
|
||||||
|
|
||||||
self->sck = g_tcp_socket();
|
self->sck = g_tcp_socket();
|
||||||
|
if (self->sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (g_tcp_connect(self->sck, ip, port) == 0)
|
if (g_tcp_connect(self->sck, ip, port) == 0)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,14 @@ sesman_main_loop(void)
|
|||||||
|
|
||||||
/*main program loop*/
|
/*main program loop*/
|
||||||
log_message(LOG_LEVEL_INFO, "listening...");
|
log_message(LOG_LEVEL_INFO, "listening...");
|
||||||
|
|
||||||
g_sck = g_tcp_socket();
|
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);
|
g_tcp_set_non_blocking(g_sck);
|
||||||
error = scp_tcp_bind(g_sck, g_cfg->listen_address, g_cfg->listen_port);
|
error = scp_tcp_bind(g_sck, g_cfg->listen_address, g_cfg->listen_port);
|
||||||
|
|
||||||
@ -132,6 +139,7 @@ sesman_main_loop(void)
|
|||||||
g_get_errno(), g_get_strerror());
|
g_get_errno(), g_get_strerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_sck != -1)
|
||||||
g_tcp_close(g_sck);
|
g_tcp_close(g_sck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,27 +203,33 @@ x_server_running_check_ports(int display)
|
|||||||
|
|
||||||
if (!x_running) /* check 59xx */
|
if (!x_running) /* check 59xx */
|
||||||
{
|
{
|
||||||
sck = g_tcp_socket();
|
if ((sck = g_tcp_socket()) != -1)
|
||||||
|
{
|
||||||
g_sprintf(text, "59%2.2d", display);
|
g_sprintf(text, "59%2.2d", display);
|
||||||
x_running = g_tcp_bind(sck, text);
|
x_running = g_tcp_bind(sck, text);
|
||||||
g_tcp_close(sck);
|
g_tcp_close(sck);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!x_running) /* check 60xx */
|
if (!x_running) /* check 60xx */
|
||||||
{
|
{
|
||||||
sck = g_tcp_socket();
|
if ((sck = g_tcp_socket()) != -1)
|
||||||
|
{
|
||||||
g_sprintf(text, "60%2.2d", display);
|
g_sprintf(text, "60%2.2d", display);
|
||||||
x_running = g_tcp_bind(sck, text);
|
x_running = g_tcp_bind(sck, text);
|
||||||
g_tcp_close(sck);
|
g_tcp_close(sck);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!x_running) /* check 62xx */
|
if (!x_running) /* check 62xx */
|
||||||
{
|
{
|
||||||
sck = g_tcp_socket();
|
if ((sck = g_tcp_socket()) != -1)
|
||||||
|
{
|
||||||
g_sprintf(text, "62%2.2d", display);
|
g_sprintf(text, "62%2.2d", display);
|
||||||
x_running = g_tcp_bind(sck, text);
|
x_running = g_tcp_bind(sck, text);
|
||||||
g_tcp_close(sck);
|
g_tcp_close(sck);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return x_running;
|
return x_running;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,12 @@ int main(int argc, char **argv)
|
|||||||
scp_init(&logging);
|
scp_init(&logging);
|
||||||
|
|
||||||
sock = g_tcp_socket();
|
sock = g_tcp_socket();
|
||||||
|
if (sock < 0)
|
||||||
|
{
|
||||||
|
LOG_DBG("Socket open error, g_tcp_socket() failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
s = scp_session_create();
|
s = scp_session_create();
|
||||||
c = scp_connection_create(sock);
|
c = scp_connection_create(sock);
|
||||||
|
|
||||||
|
@ -75,7 +75,10 @@ main(int argc, char **argv)
|
|||||||
init_stream(in_s, 8192);
|
init_stream(in_s, 8192);
|
||||||
make_stream(out_s);
|
make_stream(out_s);
|
||||||
init_stream(out_s, 8192);
|
init_stream(out_s, 8192);
|
||||||
|
|
||||||
sck = g_tcp_socket();
|
sck = g_tcp_socket();
|
||||||
|
if (sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (g_tcp_connect(sck, argv[1], g_cfg.listen_port) == 0)
|
if (g_tcp_connect(sck, argv[1], g_cfg.listen_port) == 0)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,9 @@ int main(int argc, char **argv)
|
|||||||
scp_init(&log);
|
scp_init(&log);
|
||||||
|
|
||||||
sock = g_tcp_socket();
|
sock = g_tcp_socket();
|
||||||
|
if (sock < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
s = scp_session_create();
|
s = scp_session_create();
|
||||||
c = scp_connection_create(sock);
|
c = scp_connection_create(sock);
|
||||||
|
|
||||||
|
@ -967,7 +967,14 @@ lib_mod_connect(struct vnc *v)
|
|||||||
make_stream(s);
|
make_stream(s);
|
||||||
g_sprintf(con_port, "%s", v->port);
|
g_sprintf(con_port, "%s", v->port);
|
||||||
make_stream(pixel_format);
|
make_stream(pixel_format);
|
||||||
|
|
||||||
v->sck = g_tcp_socket();
|
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_obj = g_create_wait_obj_from_socket(v->sck, 0);
|
||||||
v->sck_closed = 0;
|
v->sck_closed = 0;
|
||||||
g_sprintf(text, "VNC connecting to %s %s", v->ip, con_port);
|
g_sprintf(text, "VNC connecting to %s %s", v->ip, con_port);
|
||||||
|
@ -244,6 +244,7 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
|
|||||||
list_delete(values);
|
list_delete(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
g_file_close(fd);
|
g_file_close(fd);
|
||||||
|
|
||||||
/* startup_param overrides */
|
/* startup_param overrides */
|
||||||
|
@ -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);
|
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
||||||
fd = g_file_open(cfg_file); /* xrdp.ini */
|
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);
|
log_message(LOG_LEVEL_ERROR, "Could not read xrdp ini file %s", cfg_file);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_read_sections(fd, sections);
|
file_read_sections(fd, sections);
|
||||||
|
@ -1309,7 +1309,9 @@ xrdp_mm_get_sesman_port(char *port, int port_bytes)
|
|||||||
list_delete(values);
|
list_delete(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
g_file_close(fd);
|
g_file_close(fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +212,15 @@ lib_mod_connect(struct mod *mod)
|
|||||||
if (use_uds)
|
if (use_uds)
|
||||||
{
|
{
|
||||||
mod->sck = g_tcp_local_socket();
|
mod->sck = g_tcp_local_socket();
|
||||||
|
if (mod->sck < 0)
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mod->sck = g_tcp_socket();
|
mod->sck = g_tcp_socket();
|
||||||
|
if (mod->sck < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
g_tcp_set_non_blocking(mod->sck);
|
g_tcp_set_non_blocking(mod->sck);
|
||||||
g_tcp_set_no_delay(mod->sck);
|
g_tcp_set_no_delay(mod->sck);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user