diff options
Diffstat (limited to 'sesman')
-rw-r--r-- | sesman/chansrv/chansrv.c | 3 | ||||
-rw-r--r-- | sesman/chansrv/chansrv_fuse.c | 31 | ||||
-rw-r--r-- | sesman/chansrv/chansrv_fuse.h | 2 | ||||
-rw-r--r-- | sesman/chansrv/clipboard.c | 7 | ||||
-rw-r--r-- | sesman/chansrv/clipboard_file.c | 8 | ||||
-rw-r--r-- | sesman/chansrv/devredir.c | 29 | ||||
-rw-r--r-- | sesman/chansrv/rail.c | 3 | ||||
-rw-r--r-- | sesman/chansrv/smartcard.c | 5 | ||||
-rw-r--r-- | sesman/chansrv/smartcard_pcsc.c | 2 | ||||
-rw-r--r-- | sesman/chansrv/sound.c | 6 | ||||
-rw-r--r-- | sesman/env.c | 6 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1c.c | 1 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1c_mng.c | 2 | ||||
-rw-r--r-- | sesman/scp_v1.c | 3 | ||||
-rw-r--r-- | sesman/sesman.c | 20 | ||||
-rw-r--r-- | sesman/session.c | 6 | ||||
-rw-r--r-- | sesman/sig.c | 1 | ||||
-rw-r--r-- | sesman/tools/sesadmin.c | 10 |
18 files changed, 100 insertions, 45 deletions
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index a89957ba..6aa5c8e8 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -812,7 +812,8 @@ my_api_trans_data_in(struct trans *trans) in_uint8s(s, 12); in_uint32_le(s, bytes_read); init_stream(s, bytes_read); - trans_force_read(trans, bytes_read); + if (trans_force_read(trans, bytes_read)) + log_message(LOG_LEVEL_ERROR, "chansrv.c: error reading from transport"); } else if (g_tcp_select(trans->sck, 0) & 1) { diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 3ec00b6e..e80f93a9 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -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; } /** @@ -1779,12 +1781,15 @@ void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) new_xinode = xfuse_get_inode_from_pinode_name(fip->new_inode, fip->new_name); - if (new_xinode->mode & S_IFREG) - xfuse_delete_file_with_xinode(new_xinode); - else - xfuse_delete_dir_with_xinode(new_xinode); + if (new_xinode) + { + if (new_xinode->mode & S_IFREG) + xfuse_delete_file_with_xinode(new_xinode); + else + xfuse_delete_dir_with_xinode(new_xinode); - new_xinode = NULL; + new_xinode = NULL; + } } old_xinode = xfuse_get_inode_from_pinode_name(fip->inode, fip->name); diff --git a/sesman/chansrv/chansrv_fuse.h b/sesman/chansrv/chansrv_fuse.h index 09011452..41a73062 100644 --- a/sesman/chansrv/chansrv_fuse.h +++ b/sesman/chansrv/chansrv_fuse.h @@ -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); diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index 6d52da85..310e2093 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -1048,8 +1048,11 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status, log_debug("clipboard_process_format_announce: formatId 0x%8.8x " "wszFormatName [%s] clip_msg_len %d", formatId, desc, clip_msg_len); - g_formatIds[g_num_formatIds] = formatId; - g_num_formatIds++; + if (g_num_formatIds <= 15) + { + g_formatIds[g_num_formatIds] = formatId; + g_num_formatIds++; + } if (g_num_formatIds > 15) { log_debug("clipboard_process_format_announce: max formats"); diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c index 96f1b0e8..ff95b0a0 100644 --- a/sesman/chansrv/clipboard_file.c +++ b/sesman/chansrv/clipboard_file.c @@ -446,7 +446,13 @@ clipboard_send_file_data(int streamId, int lindex, full_fn); return 1; } - g_file_seek(fd, nPositionLow); + if (g_file_seek(fd, nPositionLow) < 0) + { + log_message(LOG_LEVEL_ERROR, "clipboard_send_file_data: seek error " + "in file: %s\n", full_fn); + g_file_close(fd); + return 1; + } make_stream(s); init_stream(s, cbRequested + 64); size = g_file_read(fd, s->data + 12, cbRequested); diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index cdcc9e94..121c1190 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -790,10 +790,14 @@ dev_redir_proc_device_iocompletion(struct stream *s) fuse_data = devredir_fuse_data_dequeue(irp); if (fuse_data == NULL) + { log_error("fuse_data is NULL"); - - xfuse_devredir_cb_read_file(fuse_data->data_ptr, s->p, Length); - devredir_irp_delete(irp); + } + else + { + xfuse_devredir_cb_read_file(fuse_data->data_ptr, s->p, Length); + devredir_irp_delete(irp); + } break; case CID_WRITE: @@ -802,10 +806,14 @@ dev_redir_proc_device_iocompletion(struct stream *s) fuse_data = devredir_fuse_data_dequeue(irp); if (fuse_data == NULL) + { log_error("fuse_data is NULL"); - - xfuse_devredir_cb_write_file(fuse_data->data_ptr, s->p, Length); - devredir_irp_delete(irp); + } + else + { + xfuse_devredir_cb_write_file(fuse_data->data_ptr, s->p, Length); + devredir_irp_delete(irp); + } break; case CID_CLOSE: @@ -879,7 +887,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 +1025,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 +1078,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 +1184,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 +1227,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 +1236,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 +1281,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 +1290,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; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 4888d2e0..f3777970 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -739,7 +739,7 @@ rail_win_get_state(Window win) (unsigned char **)&data, &nitems); - if (data || nitems > 0) + if (data && nitems > 0) { rv = *(unsigned long *)data; XFree(data); @@ -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) diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 0d6d5405..a07e36eb 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -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, diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index 1d1618dc..9824432e 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -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, diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c index cc64a558..c699ffde 100644 --- a/sesman/chansrv/sound.c +++ b/sesman/chansrv/sound.c @@ -1132,7 +1132,8 @@ sound_sndsrvr_source_data_in(struct trans *trans) return 1; ts = trans_get_in_s(trans); - trans_force_read(trans, 3); + if (trans_force_read(trans, 3)) + log_message(LOG_LEVEL_ERROR, "sound.c: error reading from transport"); ts->p = ts->data + 8; in_uint8(ts, cmd); @@ -1189,7 +1190,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 +1200,7 @@ sound_sndsrvr_source_data_in(struct trans *trans) sound_input_stop_recording(); } + xstream_free(s); + return 0; } diff --git a/sesman/env.c b/sesman/env.c index 26d1a4f7..227f6bbf 100644 --- a/sesman/env.c +++ b/sesman/env.c @@ -129,7 +129,11 @@ env_set_user(char *username, char *passwd_file, int display, { /* if no auth_file_path is set, then we go for $HOME/.vnc/sesman_username_passwd */ - g_mkdir(".vnc"); + if (g_mkdir(".vnc") < 0) + { + log_message(LOG_LEVEL_ERROR, + "env_set_user: error creating .vnc dir"); + } g_sprintf(passwd_file, "%s/.vnc/sesman_%s_passwd", pw_dir, username); } else diff --git a/sesman/libscp/libscp_v1c.c b/sesman/libscp/libscp_v1c.c index 7d1b9db8..848b3437 100644 --- a/sesman/libscp/libscp_v1c.c +++ b/sesman/libscp/libscp_v1c.c @@ -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; } diff --git a/sesman/libscp/libscp_v1c_mng.c b/sesman/libscp/libscp_v1c_mng.c index 59762e36..dc1016db 100644 --- a/sesman/libscp/libscp_v1c_mng.c +++ b/sesman/libscp/libscp_v1c_mng.c @@ -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; } diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c index 12115929..2324b750 100644 --- a/sesman/scp_v1.c +++ b/sesman/scp_v1.c @@ -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) diff --git a/sesman/sesman.c b/sesman/sesman.c index 83db5961..964bc740 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -308,9 +308,17 @@ main(int argc, char **argv) g_file_close(1); g_file_close(2); - g_file_open("/dev/null"); - g_file_open("/dev/null"); - g_file_open("/dev/null"); + if (g_file_open("/dev/null") < 0) + { + } + + if (g_file_open("/dev/null") < 0) + { + } + + if (g_file_open("/dev/null") < 0) + { + } } /* initializing locks */ @@ -361,7 +369,11 @@ main(int argc, char **argv) /* make sure the /tmp/.X11-unix directory exist */ if (!g_directory_exist("/tmp/.X11-unix")) { - g_create_dir("/tmp/.X11-unix"); + if (!g_create_dir("/tmp/.X11-unix")) + { + log_message(LOG_LEVEL_ERROR, + "sesman.c: error creating dir /tmp/.X11-unix"); + } g_chmod_hex("/tmp/.X11-unix", 0x1777); } diff --git a/sesman/session.c b/sesman/session.c index 091ce013..130ca26c 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -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; } diff --git a/sesman/sig.c b/sesman/sig.c index 7bb881ce..72892fb2 100644 --- a/sesman/sig.c +++ b/sesman/sig.c @@ -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; } diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 25af850b..979a22f9 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -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) |