From 77758c3c18baea79f889cff0382a7603a8321e80 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 15 Apr 2019 13:07:43 +0200 Subject: [PATCH] Handle empty unicode strings from server --- rdp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rdp.c b/rdp.c index b938c2f..8ac0d28 100644 --- a/rdp.c +++ b/rdp.c @@ -310,6 +310,17 @@ rdp_in_unistr(STREAM s, int in_len, char **string, uint32 * str_size) abort(); } + /* Corner case. We still want to return a null terminated string... */ + if (in_len == 0) { + if (*string == NULL) + { + *string = xmalloc(1); + } + **string = '\0'; + *str_size = 0; + return; + } + if (!s_check_rem(s, in_len)) { rdp_protocol_error("consume of unicode data from stream would overrun", &packet); @@ -358,6 +369,7 @@ rdp_in_unistr(STREAM s, int in_len, char **string, uint32 * str_size) abort(); } + /* Always force the last byte to be a null */ *pout = 0; if (*string)