Merge pull request #1887 from matt335672/stream_overflow_check

Generalise development build options, and add --enable-devel-streamcheck #1887
This commit is contained in:
matt335672 2021-05-28 11:03:00 +01:00 committed by GitHub
commit 7d8f0846d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 290 additions and 100 deletions

View File

@ -29,10 +29,6 @@ AM_CPPFLAGS = \
-DXRDP_LOG_PATH=\"${localstatedir}/log\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\"
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
# -no-suppress is an automake-specific flag which is needed
# to prevent us missing compiler errors in some circumstances
# (see https://github.com/neutrinolabs/xrdp/pull/1843 )
@ -58,6 +54,7 @@ libcommon_la_SOURCES = \
log.h \
os_calls.c \
os_calls.h \
parse.c \
parse.h \
rail.h \
ssl_calls.c \

View File

@ -25,6 +25,13 @@
#include "defines.h"
#include "list.h"
/* Check the config_ac.h file is included so we know whether to enable the
* development macros
*/
#ifndef CONFIG_AC_H
# error config_ac.h not visible in log.h
#endif
/* logging buffer size */
#define LOG_BUFFER_SIZE 8192
#define LOGGER_NAME_SIZE 50
@ -66,7 +73,7 @@ enum logReturns
/* enable threading */
/*#define LOG_ENABLE_THREAD*/
#ifdef XRDP_DEBUG
#ifdef USE_DEVEL_LOGGING
#define LOG_PER_LOGGER_LEVEL
@ -77,9 +84,10 @@ enum logReturns
* Note: all log levels are relavant to help a developer understand XRDP at
* different levels of granularity.
*
* Note: the logging function calls are removed when XRDP_DEBUG is NOT defined.
* Note: the logging function calls are removed when USE_DEVEL_LOGGING is
* NOT defined.
*
* Note: when the build is configured with --enable-xrdpdebug, then
* Note: when the build is configured with --enable-devel-logging, then
* the log level can be configured per the source file name or method name
* (with the suffix "()") in the [LoggingPerLogger]
* section of the configuration file.
@ -103,7 +111,7 @@ enum logReturns
* configure and run XRDP on their machine.
*
* Note: the logging function calls contain additional code location info when
* XRDP_DEBUG is defined.
* USE_DEVEL_LOGGING is defined.
*
* @param lvl, the log level
* @param msg, the log text as a printf format c-string
@ -116,7 +124,8 @@ enum logReturns
* @brief Logging macro for logging the contents of a byte array using a hex
* dump format.
*
* Note: the logging function calls are removed when XRDP_DEBUG is NOT defined.
* Note: the logging function calls are removed when USE_DEVEL_LOGGING is
* NOT defined.
*
* @param log_level, the log level
* @param message, a message prefix for the hex dump. Note: no printf like

66
common/parse.c Normal file
View File

@ -0,0 +1,66 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) 2021 Matt Burt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Enforce stream primitive checking
*/
#if defined(HAVE_CONFIG_H)
#include <config_ac.h>
#endif
#include <stdlib.h>
#include "arch.h"
#include "parse.h"
#include "log.h"
void
parser_stream_overflow_check(const struct stream *s, int n, int is_out,
const char *file, int line)
{
/* Sanity checks */
if (n < 0)
{
LOG(LOG_LEVEL_ALWAYS, "%s:%d "
"stream primitive called with negative n=%d",
file, line, n);
abort();
}
if (is_out)
{
/* Output overflow */
if (!s_check_rem_out(s, n))
{
LOG(LOG_LEVEL_ALWAYS, "%s:%d Stream output buffer overflow. "
"Size=%d, pos=%d, requested=%d", file, line,
s->size, (int)(s->p - s->data), n);
abort();
}
}
else
{
/* Input overflow */
if (!s_check_rem(s, n))
{
LOG(LOG_LEVEL_ALWAYS, "%s:%d Stream input buffer overflow. "
"Max=%d, pos=%d, requested=%d", file, line,
(int)(s->end - s->data), (int)(s->p - s->data), n);
abort();
}
}
}

View File

@ -28,6 +28,13 @@
#include "arch.h"
#include "log.h"
/* Check the config_ac.h file is included so we know whether to enable the
* development macros
*/
#ifndef CONFIG_AC_H
# error config_ac.h not visible in parse.h
#endif
#if defined(L_ENDIAN)
#elif defined(B_ENDIAN)
#else
@ -54,6 +61,34 @@ struct stream
int *source;
};
/** Check arguments to stream primitives
*
* This adds a function call overhead to every stream primitive and is
* intended for development only
*
* @param s stream
* @param n Bytes being requested for input/output
* @param is_out (0=input, !0=output)
* @param file __file__for caller
* @param line __line__ for caller
*
* On any kind of violation a message is output and the program is
* aborted.
*/
void
parser_stream_overflow_check(const struct stream *s, int n, int is_out,
const char *file, int line);
#ifdef USE_STREAMCHECK
# define S_CHECK_REM(s,n) \
parser_stream_overflow_check((s), (n), 0, __FILE__, __LINE__)
# define S_CHECK_REM_OUT(s,n) \
parser_stream_overflow_check((s), (n), 1, __FILE__, __LINE__)
#else
# define S_CHECK_REM(s,n)
# define S_CHECK_REM_OUT(s,n)
#endif
/******************************************************************************/
#define s_check(s) s_check_rem(s, 0)
@ -157,6 +192,7 @@ struct stream
#define in_sint8(s, v) do \
{ \
S_CHECK_REM((s), 1); \
(v) = *((signed char*)((s)->p)); \
(s)->p++; \
} while (0)
@ -164,15 +200,21 @@ struct stream
/******************************************************************************/
#define in_uint8(s, v) do \
{ \
S_CHECK_REM((s), 1); \
(v) = *((unsigned char*)((s)->p)); \
(s)->p++; \
} while (0)
/******************************************************************************/
#define in_uint8_peek(s, v) do { v = *s->p; } while (0)
#define in_uint8_peek(s, v) do \
{ \
S_CHECK_REM((s), 1); \
v = *s->p; \
} while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_sint16_le(s, v) do \
{ \
S_CHECK_REM((s), 2); \
(v) = (signed short) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
@ -183,6 +225,7 @@ struct stream
#else
#define in_sint16_le(s, v) do \
{ \
S_CHECK_REM((s), 2); \
(v) = *((signed short*)((s)->p)); \
(s)->p += 2; \
} while (0)
@ -192,6 +235,7 @@ struct stream
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint16_le(s, v) do \
{ \
S_CHECK_REM((s), 2); \
(v) = (unsigned short) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
@ -202,6 +246,7 @@ struct stream
#else
#define in_uint16_le(s, v) do \
{ \
S_CHECK_REM((s), 2); \
(v) = *((unsigned short*)((s)->p)); \
(s)->p += 2; \
} while (0)
@ -210,6 +255,7 @@ struct stream
/******************************************************************************/
#define in_uint16_be(s, v) do \
{ \
S_CHECK_REM((s), 2); \
(v) = *((unsigned char*)((s)->p)); \
(s)->p++; \
(v) <<= 8; \
@ -221,6 +267,7 @@ struct stream
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint32_le(s, v) do \
{ \
S_CHECK_REM((s), 4); \
(v) = (unsigned int) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
@ -233,6 +280,7 @@ struct stream
#else
#define in_uint32_le(s, v) do \
{ \
S_CHECK_REM((s), 4); \
(v) = *((unsigned int*)((s)->p)); \
(s)->p += 4; \
} while (0)
@ -242,6 +290,7 @@ struct stream
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint64_le(s, v) do \
{ \
S_CHECK_REM((s), 8); \
(v) = (tui64) \
( \
(((tui64)(*((unsigned char*)((s)->p + 0)))) << 0) | \
@ -258,6 +307,7 @@ struct stream
#else
#define in_uint64_le(s, v) do \
{ \
S_CHECK_REM((s), 8); \
(v) = *((tui64*)((s)->p)); \
(s)->p += 8; \
} while (0)
@ -266,6 +316,7 @@ struct stream
/******************************************************************************/
#define in_uint32_be(s, v) do \
{ \
S_CHECK_REM((s), 4); \
(v) = *((unsigned char*)((s)->p)); \
(s)->p++; \
(v) <<= 8; \
@ -282,6 +333,7 @@ struct stream
/******************************************************************************/
#define out_uint8(s, v) do \
{ \
S_CHECK_REM_OUT((s), 1); \
*((s)->p) = (unsigned char)(v); \
(s)->p++; \
} while (0)
@ -290,6 +342,7 @@ struct stream
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint16_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 2); \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
@ -298,6 +351,7 @@ struct stream
#else
#define out_uint16_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 2); \
*((unsigned short*)((s)->p)) = (unsigned short)(v); \
(s)->p += 2; \
} while (0)
@ -306,6 +360,7 @@ struct stream
/******************************************************************************/
#define out_uint16_be(s, v) do \
{ \
S_CHECK_REM_OUT((s), 2); \
*((s)->p) = (unsigned char)((v) >> 8); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 0); \
@ -316,6 +371,7 @@ struct stream
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint32_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 4); \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
@ -328,6 +384,7 @@ struct stream
#else
#define out_uint32_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 4); \
*((unsigned int*)((s)->p)) = (v); \
(s)->p += 4; \
} while (0)
@ -337,6 +394,7 @@ struct stream
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint64_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 8); \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
@ -357,6 +415,7 @@ struct stream
#else
#define out_uint64_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 8); \
*((tui64*)((s)->p)) = (v); \
(s)->p += 8; \
} while (0)
@ -365,6 +424,7 @@ struct stream
/******************************************************************************/
#define out_uint32_be(s, v) do \
{ \
S_CHECK_REM_OUT((s), 4); \
*((s)->p) = (unsigned char)((v) >> 24); \
s->p++; \
*((s)->p) = (unsigned char)((v) >> 16); \
@ -378,6 +438,7 @@ struct stream
/******************************************************************************/
#define in_uint8p(s, v, n) do \
{ \
S_CHECK_REM((s), (n)); \
(v) = (s)->p; \
(s)->p += (n); \
} while (0)
@ -385,17 +446,22 @@ struct stream
/******************************************************************************/
#define in_uint8a(s, v, n) do \
{ \
S_CHECK_REM((s), (n)); \
g_memcpy((v), (s)->p, (n)); \
(s)->p += (n); \
} while (0)
/******************************************************************************/
#define in_uint8s(s, n) \
(s)->p += (n)
#define in_uint8s(s, n) do \
{ \
S_CHECK_REM((s), (n)); \
(s)->p += (n); \
} while (0);
/******************************************************************************/
#define out_uint8p(s, v, n) do \
{ \
S_CHECK_REM_OUT((s), (n)); \
g_memcpy((s)->p, (v), (n)); \
(s)->p += (n); \
} while (0)
@ -407,6 +473,7 @@ struct stream
/******************************************************************************/
#define out_uint8s(s, n) do \
{ \
S_CHECK_REM_OUT((s), (n)); \
g_memset((s)->p, 0, (n)); \
(s)->p += (n); \
} while (0)

View File

@ -89,7 +89,7 @@
#define PREFIX(x) pixman_region##x
#endif
#ifdef XRDP_DEBUG
#ifdef USE_DEVEL_LOGGING
pixman_bool_t PREFIX(_selfcheck) (region_type_t *reg);

View File

@ -98,10 +98,22 @@ AC_ARG_ENABLE(pam-config, AS_HELP_STRING([--enable-pam-config=CONF],
[Select PAM config to install: arch, debian, redhat, suse, freebsd, macos, unix
(default: autodetect)]))
AC_ARG_ENABLE(xrdpdebug, AS_HELP_STRING([--enable-xrdpdebug],
[Build debug (default: no)]),
[], [enable_xrdpdebug=no])
AM_CONDITIONAL(XRDP_DEBUG, [test x$enable_xrdpdebug = xyes])
# Development options. devel_all is first as this provides a default for
# the others
AC_ARG_ENABLE(devel_all, AS_HELP_STRING([--enable-devel-all],
[Enable all development options (default: no)]),
[devel_all=$enableval], [devel_all=no])
AC_ARG_ENABLE(devel_debug, AS_HELP_STRING([--enable-devel-debug],
[Build exes with no optimisation and debugging symbols (default: no)]),
[devel_debug=$enableval], [devel_debug=$devel_all])
AM_CONDITIONAL(DEVEL_DEBUG, [test x$devel_debug = xyes ])
AC_ARG_ENABLE(devel_logging, AS_HELP_STRING([--enable-devel-logging],
[Enable development logging (default: no)]),
[devel_logging=$enableval], [devel_logging=$devel_all])
AC_ARG_ENABLE(devel_streamcheck, AS_HELP_STRING([--enable-devel-streamcheck],
[Add range-check/abort to stream primitives (default: no)]),
[devel_streamcheck=$enableval], [devel_streamcheck=$devel_all])
AC_ARG_ENABLE(neutrinordp, AS_HELP_STRING([--enable-neutrinordp],
[Build neutrinordp module (default: no)]),
[], [enable_neutrinordp=no])
@ -163,7 +175,7 @@ AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
AM_COND_IF([LINUX],
[AX_APPEND_COMPILE_FLAGS([-Werror])]) # bsd has warnings that have not been fixed yet
AM_COND_IF([XRDP_DEBUG],
AM_COND_IF([DEVEL_DEBUG],
[AX_APPEND_COMPILE_FLAGS([-g -O0])],
[AX_APPEND_COMPILE_FLAGS([-O2])])
@ -247,6 +259,18 @@ fi
AC_SUBST(PAM_RULES)
# Add define for development options to config_ac.h
AC_DEFINE([CONFIG_AC_H],1, [Allow sources to check config_ac.h is included])
if test x$devel_logging = xyes
then
AC_DEFINE([USE_DEVEL_LOGGING],1,[Enable development logging])
fi
if test x$devel_streamcheck = xyes
then
AC_DEFINE([USE_DEVEL_STREAMCHECK],1,[Enable development stream checking])
fi
if test "x$enable_vsock" = "xyes"
then
enable_vsock=yes
@ -451,8 +475,10 @@ echo " ipv6 $enable_ipv6"
echo " ipv6only $enable_ipv6only"
echo " vsock $enable_vsock"
echo " auth mechanism $auth_mech"
echo " debug $enable_xrdpdebug"
echo " rdpsndaudin $enable_rdpsndaudin"
echo
echo " development logging $devel_logging"
echo " development streamcheck $devel_streamcheck"
echo ""
echo " strict_locations $enable_strict_locations"
echo " prefix $prefix"

View File

@ -14,10 +14,6 @@ AM_LDFLAGS =
LIBXRDP_EXTRA_LIBS =
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
if XRDP_NEUTRINORDP
AM_CPPFLAGS += -DXRDP_NEUTRINORDP
LIBXRDP_EXTRA_LIBS += $(FREERDP_LIBS)

View File

@ -626,7 +626,7 @@ static int
xrdp_caps_process_surface_cmds(struct xrdp_rdp *self, struct stream *s, int len)
{
int cmdFlags;
#ifndef XRDP_DEBUG
#ifndef USE_DEVEL_LOGGING
/* TODO: remove UNUSED_VAR once the `cmdFlags` variable is used for more than
logging in debug mode */
UNUSED_VAR(cmdFlags);

View File

@ -611,7 +611,7 @@ xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
ls.data = mppc_enc->outputBuffer - (rdp_offset + 18);
ls.p = ls.data + rdp_offset;
ls.end = ls.p + clen;
ls.size = clen;
ls.size = s->end - s->data;
ls.iso_hdr = ls.data + iso_offset;
ls.mcs_hdr = ls.data + mcs_offset;
ls.sec_hdr = ls.data + sec_offset;

View File

@ -642,6 +642,10 @@ xrdp_sec_init(struct xrdp_sec *self, struct stream *s)
s_push_layer(s, sec_hdr, 4);
}
}
else
{
s_push_layer(s, sec_hdr, 0);
}
return 0;
}
@ -1406,7 +1410,7 @@ xrdp_sec_recv_fastpath(struct xrdp_sec *self, struct stream *s)
int len;
int pad;
#ifndef XRDP_DEBUG
#ifndef USE_DEVEL_LOGGING
/* TODO: remove UNUSED_VAR once the `ver` variable is used for more than
logging in debug mode */
UNUSED_VAR(ver);

View File

@ -5,10 +5,6 @@ AM_CPPFLAGS = \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
module_LTLIBRARIES = \
libmc.la

View File

@ -6,10 +6,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/common \
$(FREERDP_CFLAGS)
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
module_LTLIBRARIES = \
libxrdpneutrinordp.la

View File

@ -11,10 +11,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/common \
-I$(top_srcdir)/sesman/libscp
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
if SESMAN_BSD
AUTH_C = verify_user_bsd.c
AUTH_LIB =

View File

@ -11,10 +11,6 @@ AM_CPPFLAGS = \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
CHANSRV_EXTRA_LIBS =
if XRDP_FUSE

View File

@ -46,6 +46,7 @@ read_entire_packet(struct stream *src, struct stream **dest, int chan_flags,
/* packet not fragmented */
xstream_new(ls, total_length);
xstream_copyin(ls, src->p, length);
s_mark_end(ls);
ls->p = ls->data;
*dest = ls;
return 1;
@ -67,7 +68,8 @@ read_entire_packet(struct stream *src, struct stream **dest, int chan_flags,
/* in last packet, chan_flags & 0x02 will be true */
if (chan_flags & 0x02)
{
/* rewind stream */
/* terminate and rewind stream */
s_mark_end(ls);
ls->p = ls->data;
return 1;
}

View File

@ -317,6 +317,7 @@ devredir_data_in(struct stream *s, int chan_id, int chan_flags, int length,
return 0;
}
s_mark_end(g_input_stream);
g_input_stream->p = g_input_stream->data;
ls = g_input_stream;
}

View File

@ -5,10 +5,6 @@ AM_CPPFLAGS = \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
module_LTLIBRARIES = \
libscp.la

View File

@ -40,6 +40,7 @@ enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION *c, struct SCP_SES
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
c->in_s->end = c->in_s->data + 8;
in_uint32_be(c->in_s, version);

View File

@ -74,7 +74,8 @@ EnableSyslog=true
#EnableProcessId=false
[LoggingPerLogger]
; Note: per logger configuration is only used in XRDP_DEBUG builds of XRDP.
; Note: per logger configuration is only used if xrdp is built with
; --enable-devel-logging
#sesman.c=INFO
#main()=INFO
@ -139,7 +140,8 @@ EnableSyslog=true
#EnableProcessId=false
[ChansrvLoggingPerLogger]
; Note: per logger configuration is only used in XRDP_DEBUG builds of XRDP.
; Note: per logger configuration is only used if xrdp is built with
; --enable-devel-logging
#chansrv.c=INFO
#main()=INFO

View File

@ -8,10 +8,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/sesman/libscp \
-I$(top_srcdir)/sesman
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
AM_CFLAGS = $(X_CFLAGS)
bin_PROGRAMS = \

View File

@ -3,10 +3,6 @@ AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh

View File

@ -2,10 +2,6 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
check_PROGRAMS = \
memtest

View File

@ -2,10 +2,6 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
noinst_PROGRAMS = \
tcp_proxy

View File

@ -5,10 +5,6 @@ AM_CPPFLAGS = \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
module_LTLIBRARIES = \
libvnc.la

View File

@ -16,10 +16,6 @@ AM_CPPFLAGS = \
XRDP_EXTRA_LIBS =
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
if XRDP_RFXCODEC
AM_CPPFLAGS += -DXRDP_RFXCODEC
AM_CPPFLAGS += -I$(top_srcdir)/librfxcodec/include

View File

@ -454,7 +454,7 @@ main(int argc, char **argv)
const char *pid_file = XRDP_PID_PATH "/xrdp.pid";
int errored_argc;
#ifdef XRDP_DEBUG
#ifdef USE_DEVEL_LOGGING
int test;
for (test = 0; test < argc; test++)
{

View File

@ -166,7 +166,8 @@ EnableSyslog=true
#EnableProcessId=false
[LoggingPerLogger]
; Note: per logger configuration is only used in XRDP_DEBUG builds of XRDP.
; Note: per logger configuration is only used if xrdp is built with
; --enable-devel-logging
#xrdp.c=INFO
#main()=INFO

View File

@ -466,6 +466,7 @@ int
xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
{
int fd = 0;
int len = 0;
int i = 0;
int j = 0;
int k = 0;
@ -511,7 +512,15 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
/* read file size */
make_stream(s);
init_stream(s, 8192);
g_file_read(fd, s->data, 4);
if (g_file_read(fd, s->data, 4) != 4)
{
LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: missing length in file %s",
filename);
free_stream(s);
g_file_close(fd);
return 1;
}
s->end = s->data + 4;
in_uint32_le(s, size);
/* read bmp header */
if (g_file_seek(fd, 14) < 0)
@ -523,7 +532,17 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
return 1;
}
init_stream(s, 8192);
g_file_read(fd, s->data, 40); /* size better be 40 */
len = g_file_read(fd, s->data, 40); /* size better be 40 */
if (len != 40)
{
LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: "
"unexpected read length %d in file %s",
len, filename);
free_stream(s);
g_file_close(fd);
return 1;
}
s->end = s->data + len;
in_uint32_le(s, header.size);
in_uint32_le(s, header.image_width);
in_uint32_le(s, header.image_height);
@ -556,6 +575,10 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
xrdp_bitmap_resize(self, header.image_width, header.image_height);
size = header.image_width * header.image_height * 3;
init_stream(s, size);
/* Pre-fill the buffer, so if we get short reads we're
* not working with uninitialised data */
g_memset(s->data, 0, size);
s->end = s->data + size;
/* read data */
for (i = header.image_height - 1; i >= 0; i--)
@ -610,8 +633,21 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: seek error in file %s",
filename);
}
init_stream(s, 8192);
g_file_read(fd, s->data, header.clr_used * sizeof(int));
size = header.clr_used * sizeof(int);
init_stream(s, size);
/* Pre-fill the buffer, so if we get short reads we're
* not working with uninitialised data */
g_memset(s->data, 0, size);
s->end = s->data + size;
len = g_file_read(fd, s->data, size);
if (len != size)
{
LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: "
"unexpected read length in file %s",
filename);
}
for (i = 0; i < header.clr_used; i++)
{
@ -621,6 +657,10 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
xrdp_bitmap_resize(self, header.image_width, header.image_height);
size = header.image_width * header.image_height;
init_stream(s, size);
/* Pre-fill the buffer, so if we get short reads we're
* not working with uninitialised data */
g_memset(s->data, 0, size);
s->end = s->data + size;
/* read data */
for (i = header.image_height - 1; i >= 0; i--)
@ -671,8 +711,21 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: seek error in file %s",
filename);
}
init_stream(s, 8192);
g_file_read(fd, s->data, header.clr_used * sizeof(int));
size = header.clr_used * sizeof(int);
init_stream(s, size);
/* Pre-fill the buffer, so if we get short reads we're
* not working with uninitialised data */
g_memset(s->data, 0, size);
s->end = s->data + size;
len = g_file_read(fd, s->data, size);
if (len != size)
{
LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: "
"unexpected read length in file %s",
filename);
}
for (i = 0; i < header.clr_used; i++)
{
@ -682,6 +735,10 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
xrdp_bitmap_resize(self, header.image_width, header.image_height);
size = (header.image_width * header.image_height) / 2;
init_stream(s, size);
/* Pre-fill the buffer, so if we get short reads we're
* not working with uninitialised data */
g_memset(s->data, 0, size);
s->end = s->data + size;
/* read data */
for (i = header.image_height - 1; i >= 0; i--)

View File

@ -228,6 +228,7 @@ xrdp_wm_load_pointer(struct xrdp_wm *self, char *file_name, char *data,
char *mask, int *x, int *y)
{
int fd;
int len;
int bpp;
int w;
int h;
@ -256,8 +257,16 @@ xrdp_wm_load_pointer(struct xrdp_wm *self, char *file_name, char *data,
return 1;
}
g_file_read(fd, fs->data, 8192);
len = g_file_read(fd, fs->data, 8192);
g_file_close(fd);
if (len <= 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_wm_load_pointer: read error from file [%s]",
file_name);
xstream_free(fs);
return 1;
}
fs->end = fs->data + len;
in_uint8s(fs, 6);
in_uint8(fs, w);
in_uint8(fs, h);

View File

@ -5,10 +5,6 @@ AM_CPPFLAGS = \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
endif
module_LTLIBRARIES = \
libxup.la