mirror of https://github.com/neutrinolabs/xrdp
added a bunch of error checks
This commit is contained in:
parent
d2da72f5c9
commit
cf6e2abd41
|
@ -38,6 +38,7 @@
|
|||
#include <dlfcn.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -68,6 +69,10 @@ static int g_memid = 0;
|
|||
static struct xrdp_list* g_memlist = 0;
|
||||
#endif
|
||||
|
||||
/* forward declarations */
|
||||
void g_printf(char* format, ...);
|
||||
void pipe_sig(int sig_num);
|
||||
|
||||
/*****************************************************************************/
|
||||
int g_init_system(void)
|
||||
{
|
||||
|
@ -76,13 +81,15 @@ int g_init_system(void)
|
|||
|
||||
WSAStartup(2, &w);
|
||||
InitializeCriticalSection(&g_term_mutex);
|
||||
#else
|
||||
signal(SIGPIPE, pipe_sig);
|
||||
#endif
|
||||
#ifdef MEMLEAK
|
||||
g_memlist = xrdp_list_create();
|
||||
printf("some info\n\r");
|
||||
printf("sizeof xrdp_bitmap is %d\n\r", sizeof(struct xrdp_bitmap));
|
||||
printf("sizeof xrdp_wm is %d\n\r", sizeof(struct xrdp_wm));
|
||||
printf("sizeof stream is %d\n\r", sizeof(struct stream));
|
||||
g_printf("some info\n\r");
|
||||
g_printf("sizeof xrdp_bitmap is %d\n\r", sizeof(struct xrdp_bitmap));
|
||||
g_printf("sizeof xrdp_wm is %d\n\r", sizeof(struct xrdp_wm));
|
||||
g_printf("sizeof stream is %d\n\r", sizeof(struct stream));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,7 +232,7 @@ void g_hexdump(char* p, int len)
|
|||
offset = 0;
|
||||
while (offset < len)
|
||||
{
|
||||
printf("%04x ", offset);
|
||||
g_printf("%04x ", offset);
|
||||
thisline = len - offset;
|
||||
if (thisline > 16)
|
||||
{
|
||||
|
@ -233,17 +240,17 @@ void g_hexdump(char* p, int len)
|
|||
}
|
||||
for (i = 0; i < thisline; i++)
|
||||
{
|
||||
printf("%02x ", line[i]);
|
||||
g_printf("%02x ", line[i]);
|
||||
}
|
||||
for (; i < 16; i++)
|
||||
{
|
||||
printf(" ");
|
||||
g_printf(" ");
|
||||
}
|
||||
for (i = 0; i < thisline; i++)
|
||||
{
|
||||
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
|
||||
g_printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
|
||||
}
|
||||
printf("\n\r");
|
||||
g_printf("\n\r");
|
||||
offset += thisline;
|
||||
line += thisline;
|
||||
}
|
||||
|
@ -509,8 +516,14 @@ int g_tcp_select(int sck1, int sck2)
|
|||
time.tv_sec = 0;
|
||||
time.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(((unsigned int)sck1), &rfds);
|
||||
FD_SET(((unsigned int)sck2), &rfds);
|
||||
if (sck1 > 0)
|
||||
{
|
||||
FD_SET(((unsigned int)sck1), &rfds);
|
||||
}
|
||||
if (sck2 > 0)
|
||||
{
|
||||
FD_SET(((unsigned int)sck2), &rfds);
|
||||
}
|
||||
max = sck1;
|
||||
if (sck2 > max)
|
||||
{
|
||||
|
@ -934,3 +947,16 @@ int g_system(char* aexec)
|
|||
{
|
||||
return system(aexec);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void g_signal(int sig_num, void (*func)(int))
|
||||
{
|
||||
signal(sig_num, func);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void pipe_sig(int sig_num)
|
||||
{
|
||||
/* do nothing */
|
||||
g_printf("got SIGPIPE(%d)\n\r", sig_num);
|
||||
}
|
||||
|
|
|
@ -86,3 +86,4 @@ int g_load_library(char* in);
|
|||
int g_free_library(int lib);
|
||||
void* g_get_proc_address(int lib, char* name);
|
||||
int g_system(char* aexec);
|
||||
void g_signal(int sig_num, void (*func)(int));
|
||||
|
|
12
vnc/vnc.h
12
vnc/vnc.h
|
@ -14,7 +14,7 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004
|
||||
Copyright (C) Jay Sorg 2004-2005
|
||||
|
||||
libvnc
|
||||
|
||||
|
@ -35,10 +35,8 @@ struct vnc
|
|||
int (*mod_connect)(struct vnc* v);
|
||||
int (*mod_event)(struct vnc* v, int msg, int param1, int param2);
|
||||
int (*mod_signal)(struct vnc* v);
|
||||
int (*mod_invalidate)(struct vnc* v, int x, int y, int cx, int cy);
|
||||
int (*mod_end)(struct vnc* v);
|
||||
int (*mod_set_param)(struct vnc* v, char* name, char* value);
|
||||
int d1[93];
|
||||
/* server functions */
|
||||
int (*server_begin_update)(struct vnc* v);
|
||||
int (*server_end_update)(struct vnc* v);
|
||||
|
@ -51,11 +49,10 @@ struct vnc
|
|||
int (*server_set_cursor)(struct vnc* v, int x, int y, char* data, char* mask);
|
||||
int (*server_palette)(struct vnc* v, int* palette);
|
||||
int (*server_error_popup)(struct vnc* v, char* error, char* caption);
|
||||
int d2[92];
|
||||
/* common */
|
||||
int handle; /* pointer to self as int */
|
||||
int wm;
|
||||
int painter;
|
||||
long handle; /* pointer to self as int */
|
||||
long wm;
|
||||
long painter;
|
||||
int sck;
|
||||
/* mod data */
|
||||
int server_width;
|
||||
|
@ -72,4 +69,5 @@ struct vnc
|
|||
char password[256];
|
||||
char ip[256];
|
||||
char port[256];
|
||||
int sck_closed;
|
||||
};
|
||||
|
|
|
@ -428,3 +428,4 @@
|
|||
#define WM_BUTTON4DOWN 108
|
||||
#define WM_BUTTON5UP 109
|
||||
#define WM_BUTTON5DOWN 110
|
||||
#define WM_INVALIDATE 200
|
||||
|
|
|
@ -34,7 +34,7 @@ THREAD_RV THREAD_CC xrdp_listen_run(void* in_val)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//#define CLEAN_CLOSE
|
||||
#define CLEAN_CLOSE
|
||||
|
||||
/*****************************************************************************/
|
||||
int main(int argc, char** argv)
|
||||
|
|
|
@ -891,14 +891,16 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
|
|||
{
|
||||
if (self->wm->mod != 0)
|
||||
{
|
||||
if (self->wm->mod->mod_invalidate != 0)
|
||||
if (self->wm->mod->mod_event != 0)
|
||||
{
|
||||
if (rect != 0)
|
||||
{
|
||||
self->wm->mod->mod_invalidate(self->wm->mod,
|
||||
rect->left, rect->top,
|
||||
rect->right - rect->left,
|
||||
rect->bottom - rect->top);
|
||||
x = rect->left;
|
||||
y = rect->top;
|
||||
w = rect->right - rect->left;
|
||||
h = rect->bottom - rect->top;
|
||||
self->wm->mod->mod_event(self->wm->mod, WM_INVALIDATE, /* 200 */
|
||||
MAKELONG(x, y), MAKELONG(w, h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ int server_init(void)
|
|||
g_rdp_process = 0;
|
||||
make_stream(g_s);
|
||||
init_stream(g_s, 8192);
|
||||
g_mod.handle = (int)(&g_mod);
|
||||
g_mod.handle = (long)(&g_mod);
|
||||
g_mod.mod_event = mod_event;
|
||||
return 0;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ int server_loop(int sck)
|
|||
}
|
||||
if (g_mod.wm == 0)
|
||||
{
|
||||
g_mod.wm = (int)(g_rdp_process->wm);
|
||||
g_mod.wm = (long)(g_rdp_process->wm);
|
||||
}
|
||||
}
|
||||
init_stream(g_s, 8192);
|
||||
|
@ -134,7 +134,7 @@ int server_begin_update(void)
|
|||
wm = (struct xrdp_wm*)g_mod.wm;
|
||||
p = xrdp_painter_create(wm);
|
||||
xrdp_painter_begin_update(p);
|
||||
g_mod.painter = (int)p;
|
||||
g_mod.painter = (long)p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ int server_begin_update(struct xrdp_mod* mod)
|
|||
wm = (struct xrdp_wm*)mod->wm;
|
||||
p = xrdp_painter_create(wm);
|
||||
xrdp_painter_begin_update(p);
|
||||
mod->painter = (int)p;
|
||||
mod->painter = (long)p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ int xrdp_wm_setup_mod(struct xrdp_wm* self,
|
|||
}
|
||||
if (self->mod != 0)
|
||||
{
|
||||
self->mod->wm = (int)self;
|
||||
self->mod->wm = (long)self;
|
||||
self->mod->server_begin_update = server_begin_update;
|
||||
self->mod->server_end_update = server_end_update;
|
||||
self->mod->server_fill_rect = server_fill_rect;
|
||||
|
|
|
@ -555,10 +555,20 @@ int xrdp_painter_draw_text(struct xrdp_painter* self,
|
|||
draw_rect.right--;
|
||||
draw_rect.bottom--;
|
||||
flags = 0x03; /* 0x73; TEXT2_IMPLICIT_X and something else */
|
||||
DEBUG(("sending text order \
|
||||
font %d flags %d mixmode %d color1 %d color2 %d \
|
||||
clip left %d clip top %d clip right %d clip bottom %d \
|
||||
box left %d box top %d box right %d box bottom %d \
|
||||
x %d y %d len %d rect %d %d %d %d\n\r",
|
||||
f, flags, 0, font->color, 0, x, y, x + total_width,
|
||||
y + total_height, 0, 0, 0, 0, x1, y1, len,
|
||||
draw_rect.left, draw_rect.top,
|
||||
draw_rect.right, draw_rect.bottom));
|
||||
xrdp_orders_text(self->orders, f, flags, 0,
|
||||
font->color, 0,
|
||||
x, y, x + total_width, y + total_height,
|
||||
0, 0, 0, 0, x1, y1, data, len * 2, &draw_rect);
|
||||
0, 0, 0, 0,
|
||||
x1, y1, data, len * 2, &draw_rect);
|
||||
}
|
||||
}
|
||||
k++;
|
||||
|
|
|
@ -105,7 +105,7 @@ int xrdp_process_loop(struct xrdp_process* self, struct stream* s)
|
|||
int xrdp_process_main_loop(struct xrdp_process* self)
|
||||
{
|
||||
#ifndef XRDP_LIB
|
||||
int i;
|
||||
int sel_r;
|
||||
struct stream* s;
|
||||
|
||||
make_stream(s);
|
||||
|
@ -117,8 +117,16 @@ int xrdp_process_main_loop(struct xrdp_process* self)
|
|||
{
|
||||
while (!g_is_term() && !self->term)
|
||||
{
|
||||
i = g_tcp_select(self->sck, self->app_sck);
|
||||
if (i & 1)
|
||||
sel_r = g_tcp_select(self->sck, self->app_sck);
|
||||
if (sel_r == 0) /* no data on any stream */
|
||||
{
|
||||
g_sleep(10);
|
||||
}
|
||||
else if (sel_r < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (sel_r & 1)
|
||||
{
|
||||
init_stream(s, 8192);
|
||||
if (xrdp_process_loop(self, s) != 0)
|
||||
|
@ -126,7 +134,7 @@ int xrdp_process_main_loop(struct xrdp_process* self)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (i & 2) /* mod socket fired */
|
||||
if (sel_r & 2) /* mod socket fired */
|
||||
{
|
||||
if (self->wm->mod == 0)
|
||||
{
|
||||
|
@ -141,14 +149,6 @@ int xrdp_process_main_loop(struct xrdp_process* self)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0) /* no data on any stream */
|
||||
{
|
||||
g_sleep(10);
|
||||
}
|
||||
else if (i < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self->wm->mod != 0)
|
||||
|
|
|
@ -77,6 +77,7 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
|
|||
}
|
||||
else
|
||||
{
|
||||
self->sck_closed = 1;
|
||||
DEBUG((" error = -1 in xrdp_tcp_recv socket %d\n\r", self->sck));
|
||||
return 1;
|
||||
}
|
||||
|
@ -128,6 +129,7 @@ int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
|
|||
}
|
||||
else
|
||||
{
|
||||
self->sck_closed = 1;
|
||||
DEBUG((" error = -1 in xrdp_tcp_send socket %d\n\r", self->sck));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -29,10 +29,8 @@ struct xrdp_mod
|
|||
int (*mod_connect)(struct xrdp_mod* v);
|
||||
int (*mod_event)(struct xrdp_mod* v, int msg, int param1, int param2);
|
||||
int (*mod_signal)(struct xrdp_mod* v);
|
||||
int (*mod_invalidate)(struct xrdp_mod* v, int x, int y, int cx, int cy);
|
||||
int (*mod_end)(struct xrdp_mod* v);
|
||||
int (*mod_set_param)(struct xrdp_mod* v, char* name, char* value);
|
||||
int d1[93];
|
||||
/* server functions */
|
||||
int (*server_begin_update)(struct xrdp_mod* v);
|
||||
int (*server_end_update)(struct xrdp_mod* v);
|
||||
|
@ -45,11 +43,10 @@ struct xrdp_mod
|
|||
int (*server_set_pointer)(struct xrdp_mod* v, int x, int y, char* data, char* mask);
|
||||
int (*server_palette)(struct xrdp_mod* v, int* palette);
|
||||
int (*server_error_popup)(struct xrdp_mod* v, char* error, char* caption);
|
||||
int d2[92];
|
||||
/* common */
|
||||
int handle; /* pointer to self as int */
|
||||
int wm; /* struct xrdp_wm* */
|
||||
int painter;
|
||||
long handle; /* pointer to self as int */
|
||||
long wm; /* struct xrdp_wm* */
|
||||
long painter;
|
||||
int sck;
|
||||
};
|
||||
|
||||
|
@ -63,17 +60,17 @@ struct xrdp_mem
|
|||
/* header for bmp file */
|
||||
struct xrdp_bmp_header
|
||||
{
|
||||
long size;
|
||||
long image_width;
|
||||
long image_height;
|
||||
int size;
|
||||
int image_width;
|
||||
int image_height;
|
||||
short planes;
|
||||
short bit_count;
|
||||
long compression;
|
||||
long image_size;
|
||||
long x_pels_per_meter;
|
||||
long y_pels_per_meter;
|
||||
long clr_used;
|
||||
long clr_important;
|
||||
int compression;
|
||||
int image_size;
|
||||
int x_pels_per_meter;
|
||||
int y_pels_per_meter;
|
||||
int clr_used;
|
||||
int clr_important;
|
||||
};
|
||||
|
||||
/* list */
|
||||
|
|
Loading…
Reference in New Issue