summaryrefslogtreecommitdiffstats
path: root/libxrdp
diff options
context:
space:
mode:
authorspeidy <speidy@gmail.com>2017-03-16 00:39:26 +0200
committermetalefty <meta@vmeta.jp>2017-03-24 15:36:36 +0900
commit954b68314d37f9515e7f799de8a1c1a0a75476ab (patch)
tree0a62907c7747051e46bd00f209d046dc783919e4 /libxrdp
parentdfd639a3a9e5f2f84dd0694ca54a14a4258fd671 (diff)
downloadxrdp-proprietary-954b68314d37f9515e7f799de8a1c1a0a75476ab.tar.gz
xrdp-proprietary-954b68314d37f9515e7f799de8a1c1a0a75476ab.zip
xrdp_orders_rail: fix g_mbstowcs error handling
Diffstat (limited to 'libxrdp')
-rw-r--r--libxrdp/xrdp_orders_rail.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/libxrdp/xrdp_orders_rail.c b/libxrdp/xrdp_orders_rail.c
index be35789b..1556470d 100644
--- a/libxrdp/xrdp_orders_rail.c
+++ b/libxrdp/xrdp_orders_rail.c
@@ -267,7 +267,11 @@ xrdp_orders_send_window_new_update(struct xrdp_orders *self, int window_id,
/* titleInfo */
num_chars = g_mbstowcs(0, window_state->title_info, 0);
num_chars = MIN(num_chars, sizeof(twchar) * (g_strlen(window_state->title_info) + 1));
- num_chars = MAX(num_chars, 0);
+ if (num_chars < 0)
+ {
+ /* g_mbstowcs failed, ignore text */
+ num_chars = 0;
+ }
order_size += 2 * num_chars + 2;
}
@@ -545,7 +549,11 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders *self,
/* ToolTip (variable) UNICODE_STRING */
num_chars = g_mbstowcs(0, notify_state->tool_tip, 0);
num_chars = MIN(num_chars, sizeof(twchar) * (g_strlen(notify_state->tool_tip) + 1));
- num_chars = MAX(num_chars, 0);
+ if (num_chars < 0)
+ {
+ /* g_mbstowcs failed, ignore text */
+ num_chars = 0;
+ }
order_size += 2 * num_chars + 2;
}
@@ -555,12 +563,20 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders *self,
/* UNICODE_STRING */
num_chars = g_mbstowcs(0, notify_state->infotip.title, 0);
num_chars = MIN(num_chars, sizeof(twchar) * (g_strlen(notify_state->infotip.title) + 1));
- num_chars = MAX(num_chars, 0);
+ if (num_chars < 0)
+ {
+ /* g_mbstowcs failed, ignore text */
+ num_chars = 0;
+ }
order_size += 2 * num_chars + 2;
/* UNICODE_STRING */
num_chars = g_mbstowcs(0, notify_state->infotip.text, 0);
num_chars = MIN(num_chars, sizeof(twchar) * (g_strlen(notify_state->infotip.text) + 1));
- num_chars = MAX(num_chars, 0);
+ if (num_chars < 0)
+ {
+ /* g_mbstowcs failed, ignore text */
+ num_chars = 0;
+ }
order_size += 2 * num_chars + 2;
/* Timeout (4 bytes) */
/* InfoFlags (4 bytes) */