From fbc25978ae467086501ac8fbb9766f3058863ac2 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 4 Jan 2024 10:28:48 +0100 Subject: [PATCH] [common,assist] fix file parser (Fixes #9726) * only append N or U entry if it was found * append port for N and U entries --- libfreerdp/common/assistance.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index fe9f7769c..e00351516 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -660,12 +660,20 @@ static BOOL freerdp_assistance_parse_all_elements_of_l(rdpAssistanceFile* file, if (!freerdp_assistance_parse_attr(&u, &ulen, "U", data)) return FALSE; - if (!ArrayList_Append(file->MachineAddresses, strndup(n, nlen))) - return FALSE; - if (!ArrayList_Append(file->MachineAddresses, strndup(u, ulen))) - return FALSE; - if (!ArrayList_Append(file->MachinePorts, (void*)(uintptr_t)p)) - return FALSE; + if (n && (nlen > 0)) + { + if (!ArrayList_Append(file->MachineAddresses, strndup(n, nlen))) + return FALSE; + if (!ArrayList_Append(file->MachinePorts, (void*)(uintptr_t)p)) + return FALSE; + } + if (u && (ulen > 0)) + { + if (!ArrayList_Append(file->MachineAddresses, strndup(u, ulen))) + return FALSE; + if (!ArrayList_Append(file->MachinePorts, (void*)(uintptr_t)p)) + return FALSE; + } return TRUE; }