summaryrefslogtreecommitdiffstats
path: root/xrdp/xrdp.c
diff options
context:
space:
mode:
authorPavel Roskin <plroskin@gmail.com>2016-02-27 23:08:35 -0800
committerPavel Roskin <plroskin@gmail.com>2016-03-03 22:56:08 -0800
commit86ec50789c8b88dbc38926c26f068c8a469aeb4c (patch)
tree181c86d0132806c42cc989871f895cce313a3252 /xrdp/xrdp.c
parentcdb967c0f33f2c47e2ea6c1762a2bd41991064ce (diff)
downloadxrdp-proprietary-86ec50789c8b88dbc38926c26f068c8a469aeb4c.tar.gz
xrdp-proprietary-86ec50789c8b88dbc38926c26f068c8a469aeb4c.zip
Move all sanity checks to a separate function xrdp_sanity_check()
Diffstat (limited to 'xrdp/xrdp.c')
-rw-r--r--xrdp/xrdp.c81
1 files changed, 51 insertions, 30 deletions
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c
index 12fcb2fa..f985bba3 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -293,65 +293,79 @@ xrdp_process_params(int argc, char **argv,
}
/*****************************************************************************/
-int DEFAULT_CC
-main(int argc, char **argv)
+/* Basic sanity checks before any forking */
+int
+xrdp_sanity_check(void)
{
- int test;
+ int intval = 1;
int host_be;
- char cfg_file[256];
- enum logReturns error;
- struct xrdp_startup_params *startup_params;
- int pid;
- int fd;
- int no_daemon;
- char text[256];
- char pid_file[256];
-
- g_init("xrdp");
- ssl_init();
-
- for (test = 0; test < argc; test++)
- {
- DEBUG(("Argument %i - %s", test, argv[test]));
- }
/* check compiled endian with actual endian */
- test = 1;
- host_be = !((int)(*(unsigned char *)(&test)));
+ host_be = !((int)(*(unsigned char *)(&intval)));
+
#if defined(B_ENDIAN)
if (!host_be)
+ {
+ g_writeln("Not a big endian machine, edit arch.h");
+ return 1;
+ }
#endif
#if defined(L_ENDIAN)
- if (host_be)
+ if (host_be)
+ {
+ g_writeln("Not a little endian machine, edit arch.h");
+ return 1;
+ }
#endif
- {
- g_writeln("endian wrong, edit arch.h");
- return 0;
- }
/* check long, int and void* sizes */
if (sizeof(int) != 4)
{
g_writeln("unusable int size, must be 4");
- return 0;
+ return 1;
}
if (sizeof(long) != sizeof(void *))
{
g_writeln("long size must match void* size");
- return 0;
+ return 1;
}
if (sizeof(long) != 4 && sizeof(long) != 8)
{
g_writeln("unusable long size, must be 4 or 8");
- return 0;
+ return 1;
}
if (sizeof(tui64) != 8)
{
g_writeln("unusable tui64 size, must be 8");
- return 0;
+ return 1;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+int DEFAULT_CC
+main(int argc, char **argv)
+{
+ int test;
+ char cfg_file[256];
+ enum logReturns error;
+ struct xrdp_startup_params *startup_params;
+ int pid;
+ int fd;
+ int no_daemon;
+ char text[256];
+ char pid_file[256];
+
+ g_init("xrdp");
+ ssl_init();
+
+ for (test = 0; test < argc; test++)
+ {
+ DEBUG(("Argument %i - %s", test, argv[test]));
}
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
@@ -401,6 +415,13 @@ main(int argc, char **argv)
g_exit(0);
}
+ if (xrdp_sanity_check() != 0)
+ {
+ g_writeln("Fatal error occurred, exiting");
+ g_deinit();
+ g_exit(1);
+ }
+
if (startup_params->kill)
{
g_writeln("stopping xrdp");