diff --git a/common/log.c b/common/log.c index b2bab18e..bfce267a 100644 --- a/common/log.c +++ b/common/log.c @@ -495,6 +495,11 @@ internal_log_config_copy(struct log_config *dest, const struct log_config *src) { int i; + if (src == NULL || dest == NULL) + { + return; + } + dest->enable_syslog = src->enable_syslog; dest->fd = src->fd; dest->log_file = g_strdup(src->log_file); @@ -508,6 +513,21 @@ internal_log_config_copy(struct log_config *dest, const struct log_config *src) dest->console_level = src->console_level; dest->enable_pid = src->enable_pid; dest->dump_on_start = src->dump_on_start; + + if (src->per_logger_level == NULL) + { + return; + } + if (dest->per_logger_level == NULL) + { + dest->per_logger_level = list_create(); + if (dest->per_logger_level == NULL) + { + return; + } + dest->per_logger_level->auto_free = 1; + } + for (i = 0; i < src->per_logger_level->count; ++i) { struct log_logger_level *dst_logger = diff --git a/common/parse.h b/common/parse.h index b27bb0c9..a3721ef8 100644 --- a/common/parse.h +++ b/common/parse.h @@ -89,9 +89,6 @@ parser_stream_overflow_check(const struct stream *s, int n, int is_out, # define S_CHECK_REM_OUT(s,n) #endif -/******************************************************************************/ -#define s_check(s) s_check_rem(s, 0) - /******************************************************************************/ #define s_check_rem(s, n) ((s)->p + (n) <= (s)->end) diff --git a/libxrdp/Makefile.am b/libxrdp/Makefile.am index c843a531..49df6c65 100644 --- a/libxrdp/Makefile.am +++ b/libxrdp/Makefile.am @@ -45,6 +45,7 @@ libxrdp_la_SOURCES = \ xrdp_bitmap_compress.c \ xrdp_caps.c \ xrdp_channel.c \ + xrdp_channel.h \ xrdp_fastpath.c \ xrdp_iso.c \ xrdp_jpeg_compress.c \ diff --git a/libxrdp/xrdp_channel.c b/libxrdp/xrdp_channel.c index 16a8668e..fff00ece 100644 --- a/libxrdp/xrdp_channel.c +++ b/libxrdp/xrdp_channel.c @@ -24,6 +24,7 @@ #include "libxrdp.h" #include "string_calls.h" +#include "xrdp_channel.h" #define CMD_DVC_OPEN_CHANNEL 0x10 #define CMD_DVC_DATA_FIRST 0x20 @@ -31,19 +32,6 @@ #define CMD_DVC_CLOSE_CHANNEL 0x40 #define CMD_DVC_CAPABILITY 0x50 -#define XRDP_DRDYNVC_STATUS_CLOSED 0 -#define XRDP_DRDYNVC_STATUS_OPEN_SENT 1 -#define XRDP_DRDYNVC_STATUS_OPEN 2 -#define XRDP_DRDYNVC_STATUS_CLOSE_SENT 3 - -#define XRDP_DRDYNVC_STATUS_TO_STR(status) \ - ((status) == XRDP_DRDYNVC_STATUS_CLOSED ? "CLOSED" : \ - (status) == XRDP_DRDYNVC_STATUS_OPEN_SENT ? "OPEN_SENT" : \ - (status) == XRDP_DRDYNVC_STATUS_OPEN ? "OPEN" : \ - (status) == XRDP_DRDYNVC_STATUS_CLOSE_SENT ? "CLOSE_SENT" : \ - "unknown" \ - ) - #define XRDP_DRDYNVC_CHANNEL_ID_TO_NAME(self, chan_id) \ (xrdp_channel_get_item((self), (chan_id)) != NULL \ ? xrdp_channel_get_item((self), (chan_id))->name \ diff --git a/libxrdp/xrdp_channel.h b/libxrdp/xrdp_channel.h new file mode 100644 index 00000000..9f795911 --- /dev/null +++ b/libxrdp/xrdp_channel.h @@ -0,0 +1,42 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * MS-RDPEDYC : Definitions related to documentation in [MS-RDPEDYC] + * + * 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. + * + * References to MS-RDPEDYC are currently correct for v20210406 of that + * document + */ + +#if !defined(XRDP_CHANNEL_H) +#define XRDP_CHANNEL_H + +/* + These are not directly defined in MS-RDPEDYC, but + they are derived statuses needed to implement it. +*/ +#define XRDP_DRDYNVC_STATUS_CLOSED 0 +#define XRDP_DRDYNVC_STATUS_OPEN_SENT 1 +#define XRDP_DRDYNVC_STATUS_OPEN 2 +#define XRDP_DRDYNVC_STATUS_CLOSE_SENT 3 + +#define XRDP_DRDYNVC_STATUS_TO_STR(status) \ + ((status) == XRDP_DRDYNVC_STATUS_CLOSED ? "CLOSED" : \ + (status) == XRDP_DRDYNVC_STATUS_OPEN_SENT ? "OPEN_SENT" : \ + (status) == XRDP_DRDYNVC_STATUS_OPEN ? "OPEN" : \ + (status) == XRDP_DRDYNVC_STATUS_CLOSE_SENT ? "CLOSE_SENT" : \ + "unknown" \ + ) + +#endif /* XRDP_CHANNEL_H */ diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index e2a716ef..d5422483 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -1334,7 +1334,7 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status, return 0; } index = 0; - while (s_check(s)) + while (s_check_rem(s, 2)) { in_uint16_le(s, wchr); wtext[index] = wchr; diff --git a/vnc/vnc_clip.c b/vnc/vnc_clip.c index ebbfae36..364bdff7 100644 --- a/vnc/vnc_clip.c +++ b/vnc/vnc_clip.c @@ -575,7 +575,7 @@ handle_cb_format_data_response(struct vnc *v, struct stream *s) { case CF_TEXT: lastc = '\0'; - while (s_check(s)) + while (s_check_rem(s, 1)) { in_uint8(s, c); if (c == '\n' && lastc == '\r')