coverity: fixed resolution leak issues
This commit is contained in:
parent
c64b154475
commit
3bb31876e7
@ -364,7 +364,7 @@ file_by_name_read_sections(const char *file_name, struct list *names)
|
||||
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
if (fd < 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -405,7 +405,7 @@ file_by_name_read_section(const char *file_name, const char *section,
|
||||
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
if (fd < 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -284,6 +284,7 @@ internalReadConfiguration(const char *inFilename, const char *applicationName)
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_file_close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -301,6 +302,7 @@ internalReadConfiguration(const char *inFilename, const char *applicationName)
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_file_close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -367,11 +367,12 @@ save_all(char *e_data, int e_len, char *n_data, int n_len,
|
||||
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd > 0)
|
||||
if (fd != -1)
|
||||
{
|
||||
if (g_file_write(fd, "[keys]\n", 7) == -1)
|
||||
{
|
||||
g_writeln("problem writing to %s, maybe no rights", filename);
|
||||
g_file_close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -308,15 +308,18 @@ libxrdp_send_palette(struct xrdp_session *session, int *palette)
|
||||
}
|
||||
|
||||
DEBUG(("libxrdp_send_palette sending palette"));
|
||||
|
||||
/* clear orders */
|
||||
libxrdp_orders_force_send(session);
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (session->client_info->use_fast_path & 1) /* fastpath output supported */
|
||||
{
|
||||
LLOGLN(10, ("libxrdp_send_palette: fastpath"));
|
||||
if (xrdp_rdp_init_fastpath((struct xrdp_rdp *)session->rdp, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -345,6 +348,7 @@ libxrdp_send_palette(struct xrdp_session *session, int *palette)
|
||||
if (xrdp_rdp_send_fastpath((struct xrdp_rdp *)session->rdp, s,
|
||||
FASTPATH_UPDATETYPE_PALETTE) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -354,6 +358,7 @@ libxrdp_send_palette(struct xrdp_session *session, int *palette)
|
||||
RDP_DATA_PDU_UPDATE);
|
||||
}
|
||||
free_stream(s);
|
||||
|
||||
/* send the orders palette too */
|
||||
libxrdp_orders_init(session);
|
||||
libxrdp_orders_send_palette(session, palette, 0);
|
||||
@ -775,6 +780,7 @@ libxrdp_set_pointer(struct xrdp_session *session, int cache_idx)
|
||||
if (xrdp_rdp_send_fastpath((struct xrdp_rdp *)session->rdp, s,
|
||||
FASTPATH_UPDATETYPE_CACHED) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ xrdp_iso_send_cc(struct xrdp_iso *self)
|
||||
|
||||
if (trans_force_write_s(self->trans, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -705,6 +705,7 @@ xrdp_rdp_send_data_update_sync(struct xrdp_rdp *self)
|
||||
LLOGLN(10, ("xrdp_rdp_send_data_update_sync: fastpath"));
|
||||
if (xrdp_rdp_init_fastpath(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -727,6 +728,7 @@ xrdp_rdp_send_data_update_sync(struct xrdp_rdp *self)
|
||||
if (xrdp_rdp_send_fastpath(self, s,
|
||||
FASTPATH_UPDATETYPE_SYNCHRONIZE) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -1616,7 +1616,6 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec *self, struct stream *s)
|
||||
{
|
||||
int num_channels;
|
||||
int index;
|
||||
struct mcs_channel_item *channel_item;
|
||||
|
||||
DEBUG(("processing channels, channel_code is %d", self->channel_code));
|
||||
|
||||
@ -1641,10 +1640,13 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec *self, struct stream *s)
|
||||
|
||||
for (index = 0; index < num_channels; index++)
|
||||
{
|
||||
struct mcs_channel_item *channel_item;
|
||||
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
g_malloc(sizeof(struct mcs_channel_item), 1);
|
||||
if (!s_check_rem(s, 12))
|
||||
{
|
||||
g_free(channel_item);
|
||||
return 1;
|
||||
}
|
||||
in_uint8a(s, channel_item->name, 8);
|
||||
|
@ -73,7 +73,7 @@ int xfuse_create_share(tui32 device_id, char *dirname) { r
|
||||
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId) {}
|
||||
void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length) {}
|
||||
void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length) {}
|
||||
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {}
|
||||
int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {}
|
||||
void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus) {}
|
||||
void xfuse_devredir_cb_rmdir_or_file(void *vp, tui32 IoStatus) {}
|
||||
void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) {}
|
||||
@ -1422,7 +1422,7 @@ static void xfuse_update_xrdpfs_size()
|
||||
* Add a file or directory to xrdp file system
|
||||
*****************************************************************************/
|
||||
|
||||
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
|
||||
int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
|
||||
{
|
||||
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
|
||||
XRDP_INODE *xip = NULL;
|
||||
@ -1430,13 +1430,14 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
|
||||
if ((fip == NULL) || (xinode == NULL))
|
||||
{
|
||||
log_error("fip or xinode are NULL");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!xfuse_is_inode_valid(fip->inode))
|
||||
{
|
||||
log_error("inode %d is not valid", fip->inode);
|
||||
return;
|
||||
g_free(xinode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_debug("parent_inode=%d name=%s", fip->inode, xinode->name);
|
||||
@ -1444,8 +1445,8 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
|
||||
/* if filename is . or .. don't add it */
|
||||
if ((strcmp(xinode->name, ".") == 0) || (strcmp(xinode->name, "..") == 0))
|
||||
{
|
||||
free(xinode);
|
||||
return;
|
||||
g_free(xinode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
xfuse_dump_fs();
|
||||
@ -1454,9 +1455,9 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
|
||||
{
|
||||
log_debug("inode=%d name=%s already exists in xrdp_fs; not adding it",
|
||||
fip->inode, xinode->name);
|
||||
free(xinode);
|
||||
g_free(xinode);
|
||||
xip->stale = 0;
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
xinode->parent_inode = fip->inode;
|
||||
@ -1473,6 +1474,7 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
|
||||
xfuse_update_xrdpfs_size();
|
||||
|
||||
xfuse_dump_fs();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ int xfuse_file_contents_size(int stream_id, int file_size);
|
||||
int xfuse_add_clip_dir_item(char *filename, int flags, int size, int lindex);
|
||||
|
||||
/* functions that are invoked from devredir */
|
||||
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode);
|
||||
int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode);
|
||||
void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus);
|
||||
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId);
|
||||
void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length);
|
||||
|
@ -879,7 +879,7 @@ dev_redir_proc_query_dir_response(IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
FUSE_DATA *fuse_data = NULL;
|
||||
XRDP_INODE *xinode = NULL;
|
||||
XRDP_INODE *xinode;
|
||||
|
||||
tui32 Length;
|
||||
tui32 NextEntryOffset;
|
||||
@ -1017,6 +1017,7 @@ dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->completion_type = CID_CREATE_DIR_REQ;
|
||||
irp->DeviceId = device_id;
|
||||
|
||||
strcpy(irp->pathname, path);
|
||||
devredir_fuse_data_enqueue(irp, fusep);
|
||||
|
||||
@ -1069,6 +1070,7 @@ dev_redir_file_open(void *fusep, tui32 device_id, char *path,
|
||||
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = device_id;
|
||||
|
||||
strcpy(irp->pathname, path);
|
||||
devredir_fuse_data_enqueue(irp, fusep);
|
||||
|
||||
@ -1174,6 +1176,7 @@ devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->completion_type = CID_RMDIR_OR_FILE;
|
||||
irp->DeviceId = device_id;
|
||||
|
||||
strcpy(irp->pathname, path);
|
||||
devredir_fuse_data_enqueue(irp, fusep);
|
||||
|
||||
@ -1216,6 +1219,7 @@ devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
|
||||
{
|
||||
log_error("no IRP found with FileId = %d", FileId);
|
||||
xfuse_devredir_cb_read_file(fusep, NULL, 0);
|
||||
xstream_free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1224,6 +1228,7 @@ devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
|
||||
{
|
||||
/* system out of memory */
|
||||
xfuse_devredir_cb_read_file(fusep, NULL, 0);
|
||||
xstream_free(s);
|
||||
return -1;
|
||||
}
|
||||
new_irp->FileId = 0;
|
||||
@ -1268,6 +1273,7 @@ dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
|
||||
{
|
||||
log_error("no IRP found with FileId = %d", FileId);
|
||||
xfuse_devredir_cb_write_file(fusep, NULL, 0);
|
||||
xstream_free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1276,6 +1282,7 @@ dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
|
||||
{
|
||||
/* system out of memory */
|
||||
xfuse_devredir_cb_write_file(fusep, NULL, 0);
|
||||
xstream_free(s);
|
||||
return -1;
|
||||
}
|
||||
new_irp->FileId = 0;
|
||||
|
@ -1254,6 +1254,7 @@ rail_win_send_text(Window win)
|
||||
else
|
||||
{
|
||||
LOG(0, ("chansrv::rail_win_send_text: error rail_get_window_data_safe failed"));
|
||||
g_free(data);
|
||||
return 1;
|
||||
}
|
||||
if (data && len > 0)
|
||||
|
@ -861,11 +861,6 @@ scard_make_new_ioctl(IRP *irp, tui32 ioctl)
|
||||
struct stream *s;
|
||||
|
||||
xstream_new(s, 1024 * 4);
|
||||
if (s == NULL)
|
||||
{
|
||||
log_error("system out of memory");
|
||||
return s;
|
||||
}
|
||||
|
||||
devredir_insert_DeviceIoRequest(s,
|
||||
irp->DeviceId,
|
||||
|
@ -603,6 +603,7 @@ scard_process_list_readers(struct trans *con, struct stream *in_s)
|
||||
{
|
||||
LLOGLN(0, ("scard_process_list_readers: "
|
||||
"get_pcsc_context_by_app_context failed"));
|
||||
g_free(groups);
|
||||
return 1;
|
||||
}
|
||||
pcscListReaders = g_malloc(sizeof(struct pcsc_list_readers), 1);
|
||||
@ -1489,6 +1490,7 @@ scard_process_get_status_change(struct trans *con, struct stream *in_s)
|
||||
{
|
||||
LLOGLN(0, ("scard_process_get_status_change: "
|
||||
"get_pcsc_context_by_app_context failed"));
|
||||
g_free(rsa);
|
||||
return 1;
|
||||
}
|
||||
scard_send_get_status_change(user_data,
|
||||
|
@ -1189,7 +1189,6 @@ sound_sndsrvr_source_data_in(struct trans *trans)
|
||||
s_mark_end(s);
|
||||
|
||||
trans_force_write_s(trans, s);
|
||||
xstream_free(s);
|
||||
}
|
||||
else if (cmd == PA_CMD_START_REC)
|
||||
{
|
||||
@ -1200,5 +1199,7 @@ sound_sndsrvr_source_data_in(struct trans *trans)
|
||||
sound_input_stop_recording();
|
||||
}
|
||||
|
||||
xstream_free(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -215,6 +215,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION *c, int *scount,
|
||||
|
||||
if (cmd != 42)
|
||||
{
|
||||
g_free(ds);
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount,
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
g_free(ds);
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
@ -180,6 +181,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount,
|
||||
if (cmd != SCP_CMD_MNG_LIST) /* session list */
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
g_free(ds);
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
|
@ -195,8 +195,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
parseCommonStates(e, "scp_v1s_list_sessions()");
|
||||
break;
|
||||
}
|
||||
|
||||
g_free(slist);
|
||||
}
|
||||
|
||||
/* resource management */
|
||||
@ -208,6 +206,7 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
/* cleanup */
|
||||
scp_session_destroy(s);
|
||||
auth_end(data);
|
||||
g_free(slist);
|
||||
}
|
||||
|
||||
static void parseCommonStates(enum SCP_SERVER_STATES_E e, char *f)
|
||||
|
@ -759,8 +759,12 @@ session_start_fork(int width, int height, int bpp, char *username,
|
||||
|
||||
/*THREAD-FIX release chain lock */
|
||||
lock_chain_release();
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
g_free(temp->item);
|
||||
g_free(temp);
|
||||
return display;
|
||||
}
|
||||
|
||||
@ -1003,6 +1007,7 @@ session_get_bypid(int pid)
|
||||
"pid %d is null!", pid);
|
||||
/*THREAD-FIX release chain lock */
|
||||
lock_chain_release();
|
||||
g_free(dummy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1021,6 +1026,7 @@ session_get_bypid(int pid)
|
||||
|
||||
/*THREAD-FIX release chain lock */
|
||||
lock_chain_release();
|
||||
g_free(dummy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,7 @@ sig_sesman_reload_cfg(int sig)
|
||||
if (config_read(cfg) != 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "error reading config - keeping old cfg");
|
||||
g_free(cfg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -179,16 +179,16 @@ void cmndList(struct SCP_CONNECTION *c)
|
||||
(dsl[idx]).idle_days, (dsl[idx]).idle_hours, (dsl[idx]).idle_minutes, \
|
||||
(dsl[idx]).conn_year, (dsl[idx]).conn_month, (dsl[idx]).conn_day, (dsl[idx]).conn_hour, (dsl[idx]).conn_minute);
|
||||
}
|
||||
|
||||
if (0 != dsl)
|
||||
{
|
||||
g_free(dsl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("No sessions.\n");
|
||||
}
|
||||
|
||||
if (0 != dsl)
|
||||
{
|
||||
g_free(dsl);
|
||||
}
|
||||
}
|
||||
|
||||
void cmndKill(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
|
@ -231,7 +231,7 @@ get_keymaps(int keylayout, struct xrdp_keymap *keymap)
|
||||
{
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd > 0)
|
||||
if (fd != -1)
|
||||
{
|
||||
lkeymap = (struct xrdp_keymap *)g_malloc(sizeof(struct xrdp_keymap), 0);
|
||||
/* make a copy of the build in kaymap */
|
||||
|
@ -169,7 +169,7 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
|
||||
*tcp_nodelay = 0 ;
|
||||
*tcp_keepalive = 0 ;
|
||||
|
||||
if (fd > 0)
|
||||
if (fd != -1)
|
||||
{
|
||||
names = list_create();
|
||||
names->auto_free = 1;
|
||||
@ -242,9 +242,10 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
|
||||
|
||||
list_delete(names);
|
||||
list_delete(values);
|
||||
g_file_close(fd);
|
||||
}
|
||||
|
||||
g_file_close(fd);
|
||||
|
||||
/* startup_param overrides */
|
||||
if (startup_param->port[0] != 0)
|
||||
{
|
||||
|
@ -1287,9 +1287,9 @@ xrdp_mm_get_sesman_port(char *port, int port_bytes)
|
||||
|
||||
list_delete(names);
|
||||
list_delete(values);
|
||||
g_file_close(fd);
|
||||
}
|
||||
|
||||
g_file_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1414,7 +1414,7 @@ access_control(char *username, char *password, char *srv)
|
||||
int index;
|
||||
int socket = g_tcp_socket();
|
||||
|
||||
if (socket > 0)
|
||||
if (socket != -1)
|
||||
{
|
||||
/* we use a blocking socket here */
|
||||
reply = g_tcp_connect(socket, srv, "3350");
|
||||
@ -1507,6 +1507,9 @@ access_control(char *username, char *password, char *srv)
|
||||
log_message(LOG_LEVEL_ERROR, "Failure creating socket - for access control");
|
||||
}
|
||||
|
||||
if (socket != -1)
|
||||
g_tcp_close(socket);
|
||||
|
||||
return rec;
|
||||
}
|
||||
#endif
|
||||
@ -2719,10 +2722,11 @@ int read_allowed_channel_names(struct list *names, struct list *values)
|
||||
int ret = 0;
|
||||
char cfg_file[256];
|
||||
int pos;
|
||||
|
||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
||||
fd = g_file_open(cfg_file);
|
||||
|
||||
if (fd > 0)
|
||||
if (fd != -1)
|
||||
{
|
||||
names->auto_free = 1;
|
||||
values->auto_free = 1;
|
||||
|
@ -236,10 +236,11 @@ xrdp_wm_load_pointer(struct xrdp_wm *self, char *file_name, char *data,
|
||||
init_stream(fs, 8192);
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
if (fd < 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR,"xrdp_wm_load_pointer: error loading pointer from file [%s]",
|
||||
file_name);
|
||||
xstream_free(fs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -567,7 +568,7 @@ xrdp_wm_init(struct xrdp_wm *self)
|
||||
|
||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
||||
fd = g_file_open(cfg_file); /* xrdp.ini */
|
||||
if (fd > 0)
|
||||
if (fd != -1)
|
||||
{
|
||||
names = list_create();
|
||||
names->auto_free = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user